Support Forums

I need a hand on smarty please...

This is a discussion on I need a hand on smarty please... within the Technical Support forums, part of the Technical Support Forums category; Hello, Now, after the site has the first featured listings, I see that the "design" of the function.feature_listings_horizontal.php output is ...


Go Back   68 Classifieds Forums > Technical Support Forums > Technical Support

This topic is resolved.

If you have a similar issue that this thread does not address, open a new related support topic.

 
Thread Tools Display Modes
Old 06-11-2008, 07:51 AM   #1
Customer
 
Join Date: May 2008
Location: Lanzarote/spain
Posts: 71
Rep Power: 13
canariasdata is on a distinguished road
Default I need a hand on smarty please...

Hello,

Now, after the site has the first featured listings, I see that the "design" of the function.feature_listings_horizontal.php output is just going crazy.

I don't know it is just me but I would love to change the table layout of the featured listings to plain left floating divs.

I cant get the layout to work with this repeating cols and my tries of getting it nice just does not work.

For now I have this in my home.tpl but both, number of listings(8) and number of cols(5) gets ignored:


HTML Code:
{feature_listings_horizontal number=8 cols=5 table_attr='width="100%" cellpadding="3" cellspacing="3"' td_attr='style="border: 1px solid #C0C0C0; background: #FFF url(templates/estohay2/images/featbox_bg.png) repeat-x left bottom; width:20%;"'}
Which gives me this result:
www.estohay.com
scroll down to the bottom of the page and see what I am talking about.

I still do my best to propper learn PHP but this smarty stuff is really to much and I really wouldnt know how to change

HTML Code:
$output = "<table " . $table_attr.">\n";
    for ($r=0; $r<$rows; $r++) 
	{
        $output .= "<tr" . smarty_function_html_table_cycle_68('tr', $tr_attr, $c) . ">\n";
        $rx =  ($vdir == 'down') ? $r*$cols : ($rows-1-$r)*$cols;
        for ($c=0; $c<$cols; $c++) 
		{
            $x =  ($hdir == 'right') ? $rx+$c : $rx+$cols-1-$c;
            if ($inner!='cols') {
                /* shuffle x to loop over rows*/
                $x = floor($x/$cols) + ($x%$cols)*$rows;
            }
            if ($x<$loop_count) 
			{
				//format the link
				if(defined('SEO'))
to just produce a nice and clean

HTML Code:
<div class=featured>
<div class=feat_img><a href='". $link ."'><img src='".$loop[$x][image]."' border='0'  alt='".$loop[$x][title]."' /></a></div>
<div class=feat_text>" . $trailpad . "</div>
</div>
instead.

If anybody could give me a hand on this I would be very happy!

Cheers & regards,
Gregor
__________________
4.0.3 Developer
canariasdata is offline  
Old 06-11-2008, 08:52 AM   #2
curmudgeon
 
Join Date: Mar 2006
Posts: 5,366
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Just to clarify, the following line in your template is smarty...

Code:
{feature_listings_horizontal number=8 cols=5 table_attr='width="100%" cellpadding="3" cellspacing="3"' td_attr='style="border: 1px solid #C0C0C0; background: #FFF url(templates/estohay2/images/featbox_bg.png) repeat-x left bottom; width:20%;"'}
Smarty code is in the templates and is surounded by curly brackets. Whats inside these brackets can be a smarty variable (created in smarty or passed to smarty via an underlying script) or some other server variable or constant

In the case of {feature_listings_horizontal} its officially a variable but the name is registered as a smarty plugin. So what happens is the info after the name feature_listings_horizontal get passed along to the plugin itself so it can be used by the plugin.

Nw to further omplicate things, the plugin itself (ie the code you have above) is PHP, its not smarty. Sorry, dont mean to nit pick, just want to make sure we are all on the same page terminology wise.

Ok, having said all that lets take a second and look at what your asking the plugin to do. Your telling it "number=8" so you are telling the plugin to only grab 8 featured ads from the database. Then you are telling it to display "cols=5" or display those 8 ads in 5 columns. Then if we actually look at your site we see there are only 6 featured ads.

How would a person, let alone a dumb script attempt to try and layout 8 ads in 5 columns and not have empty cells?

If you look at the plugin itself you can see that there are some initial values that will be used if none are passed with the plugin call itself, one of which is "rows".

I guess what I would recommend you do is start by figuring out how many rows, columns and ads you would like displayed and then trying to logically think of the layout with the numbers you use. If you want 2 rows and 5 columns, then set you number to 10 for example. 10 would give you 2 rows of 5 columns.

I can delve deper into the code but suffice it to say that some math is done by the script using your input to try and build a nice table but if your feeding it numbers that cant create a nice even table you get skewed results.

Before you try and convert things to CSS I would try and get the actual pluging to function and return ads in a decent fashion before adding another element to the layout puzzle.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 06-11-2008, 12:17 PM   #3
Customer
 
Join Date: May 2008
Location: Lanzarote/spain
Posts: 71
Rep Power: 13
canariasdata is on a distinguished road
Default

Hello Larry, thanks for your wise explication!

I tried various combinations of numbers in cols and rows, right now I have 5 cols in 2 rows with 10 pictures. Please look at the result, if you find time.


As a professional web designer for more than 9 years, one thing I learned more than anything else: USE LAYERS when ever possible (and it is always possible).

Table are old fashioned and lack a lot of styling options. As you can see in my live example, I would not want that the empty cells -speaking only about the once that should be there (10/2=5 and not 14!) and not the 4 empty that should not be there - have any background. Now the empty cells have a BG because they are tables and not divs.
__________________
4.0.3 Developer
canariasdata is offline  
Old 06-11-2008, 12:33 PM   #4
curmudgeon
 
Join Date: Mar 2006
Posts: 5,366
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Have you made any changes to the code in the plugin itself?
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 06-11-2008, 01:17 PM   #5
Customer
 
Join Date: May 2008
Location: Lanzarote/spain
Posts: 71
Rep Power: 13
canariasdata is on a distinguished road
Default

The only change I made was centering the image by using a div around the image tag

$output.="<div align='center' class='featimg'><a href='". $link ."'><img src='".$loop[$x][image]."' border='0' alt='".$loop[$x][title]."' /></a></div><br />";

but that -just proofed it- does in now way effect the cell creation.

Also I tried deleting the default values for number, cols and rows in the function.feature_listings_horizontal.php itself and vice versa but result is still the same.
__________________
4.0.3 Developer
canariasdata is offline  
Old 06-11-2008, 01:33 PM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 133
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Can you try this:
Code:
{feature_listings_horizontal number=10 rows=2 table_attr='width="100%" cellpadding="3" cellspacing="3"' td_attr='style="border: 1px solid #C0C0C0; background: #FFF url(templates/estohay2/images/featbox_bg.png) repeat-x left bottom; width:20%;"'}
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 06-11-2008, 01:49 PM   #7
Customer
 
Join Date: May 2008
Location: Lanzarote/spain
Posts: 71
Rep Power: 13
canariasdata is on a distinguished road
Default

Heidiho Eric, that did the trick!!!

Doesn't it like the cols=5 to be defined?
__________________
4.0.3 Developer
canariasdata is offline  
Old 06-11-2008, 01:50 PM   #8
curmudgeon
 
Join Date: Mar 2006
Posts: 5,366
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Part of the problem, at least right now is that you dont have enough featured ads to nicely fill out your table. This throws off the math employed to calculate cells etc. This is really only blatantly obvious when you have a border also.

For example on a test site I specified borders so I could easily see the cells then viewed the page as I added featured ads via admin. The table wa sout of whack until I got enough featured ads on the site so the table cell count could be accuratly calculated and built.

So where does this leave us?

As I mentioned if your not using borders, custom cell backgrounds etc, people wont see the compressed emty cells so its not a big deal.

If your bound and determined to have borders and backgrounds for each cell, then you will want to specify a few number of featured ads so the current math can accuratly calculate cells. The problem is if you have an even number of cells but an odd number of ads you will still have empty cells.

Now your idea for using css may allow us to get around the above empty cells but the whole plugin will likely need to be gone over and rewritten.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Old 06-11-2008, 01:52 PM   #9
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 133
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Quote:
Originally Posted by canariasdata
Heidiho Eric, that did the trick!!!

Doesn't it like the cols=5 to be defined?
I think that was the cause. From looking at the plugin the math seems to get skewed when you define both rows and columns and don't have that many featured listings. By leaving one out it should calculate correctly the other.
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline  
Old 06-11-2008, 01:52 PM   #10
curmudgeon
 
Join Date: Mar 2006
Posts: 5,366
Rep Power: 135
Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light Lhotch is a glorious beacon of light
Default

Quote:
Originally Posted by canariasdata
Heidiho Eric, that did the trick!!!

Doesn't it like the cols=5 to be defined?
If you dont define cols it will use "4". The problem is you had less ads than you asked it to display, throwing off the math to determine total cells. Now with 10 ads and 2 rows specified its using 2 rows of 4 ads and only displaying 8 ads, which is how many you actually have o the table ends up nice and neat.
__________________
Larry

Knowledge learned is more valuable than knowledge given.
Lhotch is offline  
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Smarty "or" variable? cwp Technical Support 2 03-03-2008 02:44 PM
Image URL and Smarty Templates Kateedyd Templates, HTML, CSS, and Design Help 21 02-02-2008 02:06 PM
Smarty Templates and You. Posted BY Lhotch Eric Barnes Templates, HTML, CSS, and Design Help 13 10-02-2007 08:06 AM


All times are GMT -4. The time now is 03:32 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0