CouchCMS with the repeat tag - php

I have a code in CouchCMS to repeat generate a repetitive
<cms:folders masterpage='business.php' folder=k_folder_name>
<div class="big">
<cms:repeat count='2'>
<div class="small">
<a href="<cms:show k_folder_link />">
<img src="<cms:show k_folder_image />" />
<cms:show k_folder_name />
</a>
</div>
</cms:repeat>
</div>
</cms:folders>
The output of the above code is:
<div class="big">
<div class="small">
<a href="http://localhost/cmi/business.php?f=2">
<img src="" />
folder2
</a>
</div>
<div class="small">
<a href="http://localhost/cmi/business.php?f=2">
<img src="" />
folder2
</a>
</div>
</div>
You can see that the name folder2 is being repeated twice. And hence the output that I am getting is that the same folder image and folder name are being outputted.
My aim is to achieve the following code:
<div class="big">
<div class="small">
<a href="http://localhost/cmi/business.php?f=1">
<img src="" />
folder1
</a>
</div>
<div class="small">
<a href="http://localhost/cmi/business.php?f=2">
<img src="" />
folder2
</a>
</div>
</div>
where in folder1 and folder2 are both displayed. What changes will I need to do in the Couch coding?

The cms:folders tag itself will repeat the enclosed contents as many times as there are folders to be listed so no need for the additional cms:repeat tag. Following should produce the code you are looking for
<div class="big">
<cms:folders masterpage='business.php'>
<div class="small">
<a href="<cms:show k_folder_link />">
<img src="<cms:show k_folder_image />" />
<cms:show k_folder_name />
</a>
</div>
</cms:folders>
</div>

Related

How to get page number dynamically when genration custom TOC in mpdf?

I am trying to create custom TOC in mpdf on first page but not sure how to get the page number for dynamic content. Can anyone please help?
$html = '<div class="frame frame-top">
<div class="mpdf_toc" id="mpdf_toc_0">
<div class="mpdf_toc_level_0">
<a class="mpdf_toc_a" href="#__mpdfinternallink_1">
<span class="mpdf_toc_t_level_0">Section 1</span>
</a>
<dottab outdent="2em" />
<a class="mpdf_toc_a" href="#__mpdfinternallink_1">
<span class="mpdf_toc_p_level_0">5</span>
</a>
</div>
<div class="mpdf_toc_level_1">
<a class="mpdf_toc_a" href="#__mpdfinternallink_2">
<span class="mpdf_toc_t_level_1">Chapter 1</span>
</a>
<dottab outdent="2em" />
<a class="mpdf_toc_a" href="#__mpdfinternallink_2">
<span class="mpdf_toc_p_level_1">5</span>
</a>
</div>
<div class="mpdf_toc_level_2">
<a class="mpdf_toc_a" href="#__mpdfinternallink_3">
<span class="mpdf_toc_t_level_2">Topic 1</span>
</a>
<dottab outdent="2em" />
<a class="mpdf_toc_a" href="#__mpdfinternallink_3">
<span class="mpdf_toc_p_level_2">5</span>
</a>
</div>
</div>
You cannot, pages are determined during putting the document together when the Output() method is called and the content is finalized.

Show php image field only uploaded field

i have 3 image field like this
<?php echo $row['thumbnail1']; ?>
<?php echo $row['thumbnail2']; ?>
<?php echo $row['thumbnail3']; ?>
if there only one exp thumbnail1 is have image..
how to show
and how if only image 1 and 2 have data..
please help how to show php query if there only 1 or 2 and 3 image upload
this css style
<div class="col-xs-12">
<img src="#" class="w-full">
</div>
<!-- IF only 2 image available uploaded USE this -->
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<!-- IF only ALL/3 image available uploaded USE this -->
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
</div>
dsa sdas
Replace your old code with this (Someone edited So i have Re writtent the code again) :
<?php
if(isset($row['thumbnail1']))
{
?>
<div class="col-xs-12">
<img src="#" class="w-full">
</div>
<?php } ?>
<!-- IF only 2 image available uploaded USE this -->
<?php
if(isset($row['thumbnail2']))
{
?>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<?php } ?>
<!-- IF only ALL/3 image available uploaded USE this -->
<?php
if(isset($row['thumbnail3']))
{
?>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<div class="col-xs-4">
<img src="#" class="w-full">
</div>
<?php } ?>
Give me the update, if you have tested.

DomPDF layout breaks in PDF

I have used DOMPDF in PHP to generate PDF file. The layout seems perfect. But only when there is a page change. The layout breaks a little shifting content on right div to left side.
I guess The dompdf reads content line by line and it gets an empty space in new page on left side thus shifting right part to left. Have help to fix this ?
Here is my DOMPDF CODE
$blockHTML = "";
$blockHTML .=
'<div style="color:rgb(23, 23, 78);font-family:proximanova;letter-spacing:1px;font-size:12px;">
<div style="padding-bottom:10px;border-bottom:'.$border.'"><!--header-->
<img src="'.$logoImg.'" width="65">
</div>
<div style="margin-top:10px;">
<div style="text-align:center;padding:10px;border-bottom:'.
$border.'font-weight:bold;font-size:1.4em;">
<span>"Favorite Italian Restaurants in Los Angeles"</span>
</div>
</div>
<div style="margin-top:5px;">
<div style="text-align:center;padding:10px;">
<span style="color:rgb(179,179,179);">Collection Created By: </span>
<span> Vivek Tankaria</span>
</div>
</div>
<div style="margin-top:5px;">
<div style="text-align:center;display:inline-block;width:200px;margin:0 auto;">
<img src="'.$poiMarker.'" width="12" />
<span style="padding:0px 10px;height:15px;line-height:15px;">
48 Locations Bookmarked
</span>
</div>
</div>';
for($i=0;$i<20;$i++){
$blockHTML .= '<div style="margin-top:10px;border-top:'.$border.'">
<div style="width:100%;padding:10px 2.5%;">
<div style="display:inline-block;width:25%;">
<div>
<img src="'.$data.'" style="width:100%;height:auto;" />
</div>
</div>
<div style="display:inline-block;width:46%;padding:0 2%;">
<div style="width:100%;">
<span style="padding:2px 0;border-bottom:'.
$border.';font-weight:bold;width:70%;display:inline-block;">
Venue Name Comes Here
</span>
<span>
<img style="padding:2px;" src="'.$star.'" width="12" />
<img style="padding:2px;" src="'.$star.'" width="12" />
<img style="padding:2px;" src="'.$star.'" width="12" />
<img style="padding:2px;" src="'.$star.'" width="12" />
<img style="padding:2px;" src="'.$star.'" width="12" />
</span>
</div>
<div style="width:100%;">
<span style="padding:5px 0;width:70%;display:inline-block;">
<i>"Venue Caption Comes Here"</i>
</span>
<span style="padding:5px 0;display:inline-block;text-align:right;font-size:1.2em;width:28%;">
$$$
</span>
</div>
<div style="width:100%;">
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry standard dummy text ever since the 1500s,
when an unknown printer took a galley of type and scrambled it to make a type
</div>
</div>
<div style="display:inline-block;width:25%;">
<div>
<img src="'.$data.'" style="width:100%;height:auto;" />
</div>
</div>
</div>
<div style="width:100%;padding:10px 2.5%;">
<div style="display:inline-block;width:22%;">
<span style="display:inline-block;width:10%;padding:0 2%;"><img src="'.$call.'" width="15" /></span>
<span style="display:inline-block;width:90%;">(123) 456-7890</span>
</div>
<div style="width:1%;height:20px;display:inline-block;border-right:'.$border.'"></div>
<div style="display:inline-block;width:18%;padding:0 4% 0 2%;">
<span style="display:inline-block;width:10%;padding:2px 6%;"><img src="'.$website.'" width="18" /></span>
<span style="display:inline-block;width:90%;">www.uvwxyz.com</span>
</div>
<div style="width:1%;height:20px;display:inline-block;border-right:'.$border.'"></div>
<div style="display:inline-block;width:18%;padding:0 2%;">
<span style="display:inline-block;width:10%;padding:2px 6%;"><img src="'.$email.'" width="18" /></span>
<span style="padding:0 2%;display:inline-block;">useremail #uvwxyz.com</span>
</div>
<div style="width:1%;height:20px;display:inline-block;border-right:'.$border.'"></div>
<div style="display:inline-block;width:22%;padding:0 2%;">
<span style="display:inline-block;width:10%;padding:0 2%;"><img src="'.$address.'" width="12" /></span>
<span style="display:inline-block;width:90%;">123, Street One, Road Rd, Location (w), City - 123456</span>
</div>
</div>
</div>';
}
$blockHTML .= '</div>';
$this->load->library('dompdf_gen');
// Convert to PDF
$this->dompdf->set_paper("A4");
$this->dompdf->load_html($blockHTML);
$this->dompdf->render();
$this->dompdf->stream("welcome.pdf",array("Attachment"=>0));
Attaching Image for reference
When moving to a new page dompdf essentially starts from scratch when determining the layout. Since that's a relatively small amount of content you might try styling it with page-break-inside: avoid; to prevent breaking those elements independently.

How do I make this absolute PNG file clickable?

So I am working to make a change on this site. http://www.kbduct.com . One the site there is a png file of a transparent united states logo on the front. I had to add a small awfs logo banner to it and have the viewer be able to click on it so that it can lead to a different site. I added the anchor tags to these items but nothing happens wen you click on it. Heres the index file and the external file for the image.
BTW, I didn't build this site. Im helping to maintain it for the time being.
INDEX:
<?php include('inc/default.php');
$pageTitle = "The Nations Source For Industrial Ducting, Ducts and Ductwork Components - KB Duct";
$pageDisc = "KB Duct is the Nation's source for industrial duct, ducting components and ductwork fittings and supplies. We offer custom built solutions for your industrial needs.";
$pageKeys = "duct, ductwork, ducting, duct work, commercial ducting, industrial ducting, custom ductwork, ductwork supplies, ducting accessories, duct fittings";
?>
<!doctype html>
<html>
<?php include('inc/head.php'); ?>
<body>
<div id="sb-site">
<?php include('inc/maximage.php'); ?>
<?php include('inc/header.php'); ?>
<div class="mainarea">
<a href="http://awfsfair.org/">
<div id="eBanner" style=" position: absolute; right: 380px; top: 310px;">
<?php /*?> <script type='text/javascript' src='http://libs.a2zinc.net/Common/JS/10.6.0.0/a2zWidget.js'></script><script type='text/javascript' id='exWidget'>new a2z.Widget('dGbJ%2fQfPqUA4s%2fDNrIc%2fzt5xiq%2fL4ZoFjVXmdUEcJutOcD9ggxZSCZyU8MZ6cQu6',40297,'http://libs.a2zinc.net/Common/Widgets/ExhibitorBadge.aspx',31,201133,330,200).render();</script>
<?php */?>
</a>
</div>
<div class="wrapper">
<?php include('inc/industry.php'); ?>
<?php include('inc/catatypes.php'); ?>
<div id="mob-only">
<?php include('inc/mobslideup.php'); ?>
</div>
</div>
</div>
<?php include('inc/footer.php'); ?>
</div>
<?php include('inc/mob-menu.php'); ?>
</body>
</html>
MAXIMAGE.PHP:
<div id="maximage">
<div>
<img src="img/Custom-Ductwork-Clamp-Together-Ducting-Shiny-Ducts-BG.jpg" alt="KB Duct is the nation's source for clamp together and flanged industrial ducting and duct parts." />
<div class="in-slide-content" style="display:none;">
<img src="img/nations-source-for-industrial-ducting.png" alt="KB Duct offers custom fabricated industrial ducting solutions.">
</div>
</div>
<div>
<img src="img/shinyduct.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
<!-- <div>
<img src="img/kbduct-production.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/nations-source-for-industrial-ducting.png">
</div>
</div>-->
<div>
<img src="img/plasma.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
<div>
<img src="img/welding.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
<!-- <div>
<img src="img/clamp.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/nations-source-for-industrial-ducting.png">
</div>
</div>-->
<div>
<img src="img/tunnel.jpg" alt="" />
<div class="in-slide-content" style="display:none;">
<img src="img/awfs-nations-source.png">
</div>
</div>
MAXIMAGE CSS ID:
#maximage {
display:block;/* Only use this if you fade it in again after the images load */
position:fixed !important;
z-index:-1;

Unable to get span tag using xpath

<div class="product_box">
<div class="list_sale">
<img src="link" class="listsale" alt="">
<div class="product_box_title">
<strong>title here</strong>
</div>
<div class="product_box_desc">
some text here
<strike>some text</strike>
<br />
<span class="list_price">THIS IS THE NEEDED TEXT</span>
<strong>some text</strong>
</div>
<div class="list_buynow">
<form action="link" class="add_to_cart" method="post">
<div class="add_cart">
<input type="image" src="link" value="add_to_cart" class="add_button">
<input id="fast_order_0_item_code" type="hidden" name="fast_order[0] [item_code]" value="value" class="item_code"/>
<input name="fast_order[0][add]" value="1" class="add_qty">
<input type="hidden" name="redirect_uri" value="value">
</div>
</form>
</div>
<div class="product_box_img">
<a href="link">
<img src="http://stacktoheap.com/images/stackoverflow.png" alt="">
</a>
</div>
</div>
</div>
This is my html file and from this div I need to extract "THIS IS THE NEEDED TEXT". I Had been able to get the div with class "product_box_desc" and from that I am able to get the text under it "some text here". But I am unable to fetch the span which contains the text. Here is the XPATH query I am using, please suggest what has to be changed.
$dom_xpath->query("//div[#class='product_box']/div/div[#class='product_box_desc']/span[#class='list_price']")
This query works fine for me :
//div[#class="product_box"]/div[#class="list_sale"]/div[#class="product_box_desc"]/span[#class="list_price"]
But I change the html to this one :
<div class='product_box'>
<div class='list_sale'>
<img src='link' class='listsale' alt='' />
<div class='product_box_title'>
<a href='link'><strong>title here</strong></a>
</div>
<div class='product_box_desc'>
some text here
<strike>some text</strike>
<br />
<span class='list_price'>THIS IS THE NEEDED TEXT</span>
<a href='link'><strong>some text</strong></a>
</div>
<div class='list_buynow'>
<form action='link' class='add_to_cart' method='post'>
<div class='add_cart'>
<input type='image' src='link' value='add_to_cart' class='add_button'>
<input id='fast_order_0_item_code' type='hidden' name='fast_order[0] [item_code]' value='value' class='item_code'/>
<input name='fast_order[0][add]' value='1' class='add_qty'>
<input type='hidden' name='redirect_uri' value='value'>
</div>
</form>
</div>
<div class='product_box_img'>
<a href='link'>
<img src='http://stacktoheap.com/images/stackoverflow.png' alt=''>
</a>
</div>
</div>
</div>
One mistake was here :
<a href='link'><strong>title here</strong></a> instead of
<a href='link'><strong>title here</a></strong>
I do this :
$nodes = ($xPath->query('//div[#class="product_box"]/div[#class="list_sale"]/div[#class="product_box_desc"]/span[#class="list_price"]'));
foreach($nodes as $node) {
echo $node->textContent;
}

Categories