|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Tonata Smarty Rookie
Joined: 28 Jun 2010 Posts: 5
|
Posted: Mon Jun 28, 2010 11:03 am Post subject: Rename Variable value |
|
|
Hi all,
Im quite new to using Smarty, I want to rename or modify variable content..
Here's the deal, I am dynamically displaying images from the DB, i display thumbnails and on click of the thumbnail i want it to display the bigger version of that image.
I have a naming conversion for my images, for example: Code: |
//GAL_17_1_Lighthouse --> small/thumbnail image for lighthouse
//GAL_17_2_Lighthouse --> big image for lighthouse
|
notice that the last number changes, 1 for small, and 2 for a bigger version of that image... hope its clear there..
in the DB i only store the name of the thumbnail, so in my PHP file I select the name of the image
Code: |
$sql=SELECT image_name
FROM images_table;
//execute my SQL statement
$image = sqlExecute($connection, $sql, $sqlError, $sqlCount, basename(__FILE__), DEBUG);
$tmplEngine->assign(
array(
'thumbnails' => $image,
)
);
|
and then in my HTM file i display the thumbnail
Code: |
{section name=list loop=$thumbnails}
<tr >
<td><a href="images/{$thumbnails[list].image_name}" rel="enlargeimage" rev="targetdiv:loadarea2,trigger:click,preload:none,fx:reveal"><img src="images/{$thumbnails[list].image_name}"></a><br /></td>
</tr>
{/section}
|
The above code displays thumbnails as links, on click of a thumbnail it displays a thumbnail again of that image, but that is not what i want, i want it to display the bigger version, by simply modifying the HREF attribute. Is there a way to modify the value for {$thumbnails[list].image_name}? If it is not possible, can you please give me a few tips on how i can achieve this dynamically... Thank you in advance |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 28, 2010 6:52 pm Post subject: |
|
|
Not to dodge the question, but there is a better way to handle your situation. In PHP when you select the image name from the db, supply both the thumbnail and large image filenames in an array (or as separate variable names.) Then the template can just display the correct filename and not deal with filename assembly. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|