I want to draw every 7 images inside row, how make it by Smarty?
<table width="838" cellpadding="0" cellspacing="0" style="border-collapse:collapse">
{section name=index loop=$ArrGallery}
<tr>
<td>
<img src="{$ArrGallery[index].gallery_path}" width="150" height="100" style=" position:relative; z-index:1; padding:7px;"/>
Delete
</td>
</tr>
{/section}
</table>
Instead of a table with a fixed number of cells per row, use css's float property. The objects you float will stack themselves onto the left side of their container until they fill it, then fill the next row, and so on. By adjusting the width of the container, you control the number of items per row. For example:
<div style="width:560px;">
{section name=index loop=$ArrGallery}
<img src="{$ArrGallery[index].gallery_path}" style="float:left;width:150px;height:100px;padding:7px;"/>
{/section}
</div>
Adjust the div's width until 7 images fill each row (except perhaps the last row).
Related
I'm trying to align images to the bottom of a td element to achieve something like this (the three images, independently from the height of the other images, will be always on the bottom of the td):
Expectative:
With the following markup:
<?php
// create some HTML content
$html = '<h1>Image alignments on HTML table</h1>
<table cellpadding="0" cellspacing="0" border="1" style="text-align:center;">
<tr>
<td width="33%">
<img src="signature1.png" border="0" align="bottom"/>
</td>
<td width="33%">
<img src="signature2.png" border="1" align="bottom" style="margin-bottom: 0px;" />
</td>
<td width="33%" align="bottom">
<img src="signature3.png" border="0" align="bottom" style="padding: 5px;" />
</td>
</tr>
</table>';
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
//Close and output PDF document
$pdf->Output('example_006.pdf', 'I');
However TCPDF doesn't support padding nor margin rules and i'm getting the following result:
Reality:
In the official documentation there's the align bottom property but it doesn't work.
Note: it's worth to say that the images don't have transparent pixels
around them (on top or bottom where it matters ... ) e.g:
Thanks in advance !
Pitifully TCPDF ended up without support for padding or margin, which means that what i needed wasn't technically possible. I decided to move to Dompdf that allows this behaviour using CSS rules (specifically vertical align, mentioned in this article).
I've been working on this all day and have tried every possible solution I could find but nothing seems to be working. Here's a copy of my code (using Smarty template system):
<tr><td style="border-top: none;">
<table>
<tr><th colspan="7">TITLE OF THE TABLE</th></tr>
{foreach from=$data.history item=tmp name=item}
<tr><td colspan="1" class='{cycle name=color values="odd,even"}'>{$tmp->history}</td></tr>
{/foreach}
</table>
</td><tr>
If you looks in the foreach statement you'll see that I'm trying to create a new td for each piece of information. This is actually working. However, the problem is that it's not spanning them in the table like I want it to do.
I want each td to have its own column and for there to be a maximum of 7 columns. As of right now, there's only one column showing and every is just split between rows.
Ideally, I want there to be 7 columns per row, even if some of them have to be empty because there's not enough data to pull. Is there any way to do this?
I think you are missing a final </tr>
<tr><td style="border-top: none;">
<table>
<tr><th colspan="7">TITLE OF THE TABLE</th></tr>
{foreach from=$data.history item=tmp name=item}
<tr><td colspan="1" class='{cycle name=color values="odd,even"}'>{$tmp->history}</td></tr>
{/foreach}
</table>
</td><tr>
^^^ ------------> should be </tr>
Edit: Added example below.
I have the following code (simplified for example) which I send as newsletter:
<table width="700">
<tr>
<td width="700"><!-- Really trying to set 700 as max) -->
<table width="700"> <!-- simple table content, not bigger than 700 --></table>
<table width="350"> <!-- simple table content, not bigger than 350 --></table>
<table width="350"> <!-- simple table content, not bigger than 350 --></table>
</td>
</tr>
</table>
Expected result:
[------ table 700 ------]
[ table 350 ][ table 350 ]
Result in Windows Live Mail: (working fine in Mac's Mail)
[------ table 700 ------][ table 350 ][ table 350 ]
It's all in 1 row, though the wrapping TD and table are set to 700, I'm expected it starting on new lines.
I can not add breaks, this is dynamic code, I have more parts, and I dont know in the code which is the last of a line.
I can't find topics about this, other than "start sending mails, with tables"-novice solutions.
Anyone got a clue?
The problem/solution is using align="left". Any table with align=left will have the next table stuck to it. Example of prefered result:
[---- 100 ----]
[--50--][--50--]
[25][25][25][25]
If all those tables have align="left", it would result in one long line:
[---- 100 ----][--50--][--50--][25][25][25][25]
I removed the align=left from the first table, which results like this:
[---- 100 ----]
[--50--][--50--][25][25][25][25]
I can'r remove the align=left from the other tables, because I want those inline-block. In order to get them properly, I added a 'split' in my code. The split-table is a table without the align=left and no height. All tables haves align=left, apart from the split:
[---- 100 ----](split)
[--50--][--50--](split)
[25][25][25][25]
Add style="display:block;" to your top table.
However you'd be better off putting them into their own <td>'s instead of float/aligning them there.
Like this:
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#eeeeee">
...
</td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="350" bgcolor="#cccccc">
...
</td>
<td width="350" bgcolor="#dddddd">
...
</td>
</tr>
</table>
</td>
</tr>
</table>
Here is a similar question/answer here that explains another issue you'd likely face with aligning tables like you have.
If you are trying to go responsive, you can use <td>'s with display:block; instead to make them 'pop' down when the media query triggers. Example here
i have categories and subs and i want draw every category with sub in td. i write this code but it draw all category with sub in one td. what is the problem? thank you
{section name=catsubs loop=$arrClientsCategorySub}
<td width="28" height="26" align="center" style="background-image:url(images/categorycolor.png); background-repeat:no-repeat; background-color:{$arrClientsCategorySub[catsubs].color}">
{section name=catsub2 loop=$arrClientsCategorySub[catsubs].arrsubCompanies}
<a id="ict-font-inner5sub" href="categoriescompanies.php?categoryid={$arrClientsCategorySub[catsubs].arrsubCompanies[catsub2].catsubid}">{$arrClientsCategorySub[catsubs].arrsubCompanies[catsub2].catsubnumber}</a>
{/section}
</td>
<td width="5"></td>
{/section}
I think your <td> code needs to go one {section} deeper to go around every subcateogry. Try this:
{section name=catsubs loop=$arrClientsCategorySub}
{section name=catsub2 loop=$arrClientsCategorySub[catsubs].arrsubCompanies}
<td width="28" height="26" align="center" style="background-image:url(images/categorycolor.png); background-repeat:no-repeat; background-color:{$arrClientsCategorySub[catsubs].color}">
<a id="ict-font-inner5sub" href="categoriescompanies.php?categoryid={$arrClientsCategorySub[catsubs].arrsubCompanies[catsub2].catsubid}">{$arrClientsCategorySub[catsubs].arrsubCompanies[catsub2].catsubnumber}</a>
</td>
{/section}
<td width="5"></td>
{/section}
Also, your code will be a lot more efficient and lightweight if your <td> was assigned a styled class instead of all that code in the long style tag.
If I have these two tables:
<table>
<tr>
<td>Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
How can I make it so that the two columns have the same width?
I can't combine the tables so thats not an option. I also can't use fixed widths since its dynamic content. Any ideas? Perhaps something in javascript to have the top columns match the width of the lower table? I'm no js expert so I have no idea if thats possible or how to do it. Php is an option on the table as well if theres a way to use that to solve it as well.
Are you able to define css for this dynamic content? Suppose these tables were nested inside a div like so:
<div id="content">
<table>
<tr>
<td>Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
</div>
I would write some css like this:
#content table td { width: 80%; }
I would use a percentage-based width on the 'flowing' column, and buffer it with fixed-width columns if necessary. ie.:
<table style="width: 100%;">
<tr>
<td style="width: 80%;">Small Length Content</td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td style="width: 80%;">Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
You can use CSS to accomplish this. You will have to have the longer content wrap.
td{
width:80%;
}
Try
<table>
<tr>
<td style="width:200px">Small Length Content</td>
</tr>
</table>
<table>
<tr>
<td>Dynamic Content Goes Here And It's Longer Than The TD Above</td>
</tr>
</table>
or add a class to name to the td element and define the style somewhere else like an external file or in header style