Currently the wishlist module in my Prestashop store only displays the product image and title. There are two wishlist views, the customer account view and the shared link view. I would like to display the price in both of these views. I've tried adding
$price = Product::getPriceStatic($productid);
to different parts of managewishlist.php and adding
<span id="our_price_display">{convertPrice price=$productPrice}</span>
to the managewishlist tpl file but nothing shows up. I'm running version 1.5.6.2.
EDIT: I also tried adding
{if !$priceDisplay || $priceDisplay == 2}
{assign var='productPrice' value=$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}
{assign var='productPriceWithoutReduction' value=$product->getPriceWithoutReduct(false, $smarty.const.NULL)}
{elseif $priceDisplay == 1}
{assign var='productPrice' value=$product->getPrice(false, $smarty.const.NULL, $priceDisplayPrecision)}
{assign var='productPriceWithoutReduction' value=$product->getPriceWithoutReduct(true, $smarty.const.NULL)}
{/if}
to managewishlist.tpl but it made the wishlist disappear
Not sure about the actual files you need to edit but this should be right for PS 1.5.x
in blockwishlist/view.php add the commented line:
for ($i = 0; $i < sizeof($products); ++$i)
{
$obj = new Product($products[$i]['id_product'], false, $context->language->id);
if (!Validate::isLoadedObject($obj))
continue;
else
{
if ($products[$i]['id_product_attribute'] != 0 && isset($combination_imgs[$products[$i]['id_product_attribute']][0]))
{
$combination_imgs = $obj->getCombinationImages($context->language->id);
$products[$i]['cover'] = $obj->id.'-'.$combination_imgs[$products[$i]['id_product_attribute']][0]['id_image'];
}
else
{
$images = $obj->getImages($context->language->id);
foreach ($images AS $k => $image)
{
if ($image['cover'])
{
$products[$i]['cover'] = $obj->id.'-'.$image['id_image'];
break;
}
}
if (!isset($products[$i]['cover']))
$products[$i]['cover'] = $context->language->iso_code.'-default';
}
// ADD THIS LINE!
$products[$i]['price'] = Product::getPriceStatic($obj->id);
}
}
then in view.tpl (not sure if PS 1.5.x uses the /templates/view/ dir or not try both) you can just use {convertPrice price=$product.price} wherever you need.
Haven't actually tested this but it should give you a good starting point at least.
EDIT Also please be aware that that editing module files directly is not recommended. However, since there is no option to override modules in PS 1.5.x your only options are:
a) editing module directly - meaning it will break if / when you update said module
b) copying the module and renaming it - which is messy but imho preferable to the downside of a)
I'm working with WHMCS and I notice that list views are not working well.
That's because in the clientarea's list views I have tousans thousands of records to display and the DataTables is crashing.
Is there a way to paginate from the server-side? I will appreciate any idea.
Here is an idea: let' say you are viewing the Domains list page, you can use ClientAreaPage hook to create a variable to load a "paged" copy of domains:
add_hook( 'ClientAreaPage', 1, function( $vars )
{
$myVars = array();
if (App::getCurrentFilename() == 'clientarea' && isset($_GET['action']) && $_GET['action'] == 'domains') {
$domains2 = array();
foreach($vars['domains'] as $k => $domain) {
if ($k < 3) {//your code to handle pagination
$domains2[] = $domain;
}
}
$myVars['domains2'] = $domains2;
$myVars['currentpage'] = 1;
}
return $myVars;
});
In clientareadomains.tpl (template file), you need to change $domains to $domains2:
{foreach key=num item=domain from=$domains2}
Of course, it is not simple task, you need to handle pagination in the hook and the tpl files.
Hope it helps.
I am using Dojo v1.8 with Worklight; I would like create a SwapView dynamically in View, but I'm encountering problems...
HTML code:
<div data-dojo-type="dojox.mobile.View" id="listeInscriptionView"
data-dojo-props="selected:false,scrollDir:'vh'"
style="background-image: url('images/bg-texture.jpg');"
data-dojo-id="id">
</div>
JavaScript code:
var view = registry.byId(listeInscriptionView);
alert(view);
for(var i = 1; i < 3; i++ ){
var swap = new dojox.mobile.SwapView({
id: i,
selected:false
});
var head = new dojox.mobile.Heading({
label:'Swap' + i,
});
swap.addChield(head);
view.addChield(swap);
alert("test" + i);
}
The above does not work. How I can create the widget SwapView dynamically?
Is that a copy of your actual code? I have not actually tested it but there are syntax errors and typos:
registry.byId(listeInscriptionView);
should be
registry.byId("listeInscriptionView");
(missing quotes), and
swap.addChield(head);
view.addChield(swap);
should be
swap.addChild(head);
view.addChild(swap);
Maybe it works better with these errors fixed?
*JS*
document.getElementsByClassName('abc')[0].setAttribute('id', 'abe');
*html*
<div class="abc"></div>
<div class="abc"></div>
How to make this script work with more than one element?
Some thing like this
var divs = document.getElementsByClassName('abc');
for (i = 0; i < divs.length; i++) {
divs[i].setAttribute('id', 'abe');
}
I am using TCPDF to generate the PDF in one of my projects. I simply create a HTML file and give it to the TCPDF to handle the PDF generation. But now I have some HTML where multiple certificates are added one after the other and I want to have a page break in it. Page Break should be decided by HTML i.e. I want to know if there is any identifier in HTML which TCPDF understands and then accordingly adds a page break into the generated PDF.
How could I do this?
I'm using <br pagebreak="true"/>.
Find method writeHTML and code
if ($dom[$key]['tag'] AND isset($dom[$key]['attribute']['pagebreak'])) {
// check for pagebreak
if (($dom[$key]['attribute']['pagebreak'] == 'true') OR ($dom[$key]['attribute']['pagebreak'] == 'left') OR ($dom[$key]['attribute']['pagebreak'] == 'right')) {
// add a page (or trig AcceptPageBreak() for multicolumn mode)
$this->checkPageBreak($this->PageBreakTrigger + 1);
}
if ((($dom[$key]['attribute']['pagebreak'] == 'left') AND (((!$this->rtl) AND (($this->page % 2) == 0)) OR (($this->rtl) AND (($this->page % 2) != 0))))
OR (($dom[$key]['attribute']['pagebreak'] == 'right') AND (((!$this->rtl) AND (($this->page % 2) != 0)) OR (($this->rtl) AND (($this->page % 2) == 0))))) {
// add a page (or trig AcceptPageBreak() for multicolumn mode)
$this->checkPageBreak($this->PageBreakTrigger + 1);
}
}
You might use TCPDF's AddPage() method in combination with explode() and a suitable delimiter:
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8',
false);
// TCPDF initialization code (...)
$delimiter = '<h1>';
$html = file_get_contents('./test.html');
$chunks = explode($delimiter, $html);
$cnt = count($chunks);
for ($i = 0; $i < $cnt; $i++) {
$pdf->writeHTML($delimiter . $chunks[$i], true, 0, true, 0);
if ($i < $cnt - 1) {
$pdf->AddPage();
}
}
// Reset pointer to the last page
$pdf->lastPage();
// Close and output PDF document
$pdf->Output('test.pdf', 'I');
I tried using
<br pagebreak="true" />
or
<tcpdf method="AddPage" />
each of them resulted not in starting new page at the top of the page but adding the full A4-page empty space in between HTML text. So if text ended in the middle of the page and then page break was inserted, the new text was written from the middle of the next page. Which I didn't want.
What worked was this (found it here TCPDF forcing a new page):
$pdf->writeHTML($content, true, 0, true, 0);
$pdf->AddPage();
$pdf->setPage($pdf->getPage());
This now starts with writing text on top of the page.
TCPDF support the 'pagebreak' attribute for HTML tags and CSS properties 'page-break-before' and 'page-break-after'.
For example you can use <br pagebreak="true" />.
Check the official http://www.tcpdf.org website and forums for further information.
With version 5.9.142 from 2011-12-23 we could use the page-break-before, page-break-inside css properties, like this:
<div style="page-break-inside:avoid;">
some non breakable text
</div>
For someone who still has the same problem with page-break TCPDF library
You can use <div style="page-break-before:always"></div> OR <br pagebreak="true"/>
to break page manually in your HTML content.
Use $tcpdf->AddPage() to break page manually in your code.
When you set SetAutoPageBreak(TRUE, 10); that means: when the height of document reach to (bottom - 10) then move the cursor to new page. So if you want to have more space, just reduce the number into 0. It will draw until the end of the document without any margin from bottom.
Remember that TCPDF only accept the double quote (") for attributes of tags. Don't use single quote (') for your tag.
<div style='page-break-before:always' => WRONG
<div style="page-break-before:always" => RIGHT
It takes 8 hours from me because this issue :(
According to http://www.tcpdf.org/examples/example_049.phps you can use something like this
$html .= '<tcpdf method="AddPage" /><h2>Graphic Functions</h2>';
You need to verify that parameter K_TCPDF_CALLS_IN_HTML in TCPDF configuration file is true.
You can also follow this method to accomplish your needs:
$htmlcontent1="CERTIFICATE NUMBER 1 IMAGE HERE";
// output the HTML content
$pdf->writeHTML($htmlcontent1, true, 0, true, 0);
// reset pointer to the last page
$pdf->lastPage();
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Print a table
// add a page
$pdf->AddPage();
$htmlcontent1="CERTIFICATE NUMBER 1 IMAGE HERE";
// output the HTML content
$pdf->writeHTML($htmlcontent1, true, 0, true, 0);
// reset pointer to the last page
$pdf->lastPage();
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('textcertificate.pdf', 'D');
Hopes it helps someone :)
Thanks
Giving your element the page-break-after, page-break-before or page-break-inside property via CSS will apply the attribute pagebreak or pagebreakafter to the html tag during TCPDF runtime.
// page-break-inside
if (isset($dom[$key]['style']['page-break-inside']) AND ($dom[$key]['style']['page-break-inside'] == 'avoid')) {
$dom[$key]['attribute']['nobr'] = 'true';
}
// page-break-before
if (isset($dom[$key]['style']['page-break-before'])) {
if ($dom[$key]['style']['page-break-before'] == 'always') {
$dom[$key]['attribute']['pagebreak'] = 'true';
} elseif ($dom[$key]['style']['page-break-before'] == 'left') {
$dom[$key]['attribute']['pagebreak'] = 'left';
} elseif ($dom[$key]['style']['page-break-before'] == 'right') {
$dom[$key]['attribute']['pagebreak'] = 'right';
}
}
// page-break-after
if (isset($dom[$key]['style']['page-break-after'])) {
if ($dom[$key]['style']['page-break-after'] == 'always') {
$dom[$key]['attribute']['pagebreakafter'] = 'true';
} elseif ($dom[$key]['style']['page-break-after'] == 'left') {
$dom[$key]['attribute']['pagebreakafter'] = 'left';
} elseif ($dom[$key]['style']['page-break-after'] == 'right') {
$dom[$key]['attribute']['pagebreakafter'] = 'right';
}
}