Jump to content

batch images in category page


njohn

Recommended Posts

I need to put 64+ images in a two column table. Doing it one by one would be quite troublesome and in addition I'll want to do it several times with different images on several pages. Is it possible/how to do?

 

Link to comment
Share on other sites

It seems like what you want is for some sort of automation. If so, then Smarty can accept an array and build a table around it.

So, the following is a concise example:

$imgArray = (
 "image1.jpg",
 "image2.jpg",
 "image3.jpg",
 "image4.jpg",
);
$GLOBALS['smarty']->assign('imgArray', $imgArray);

Then, in the template where you want the table:

{* See http://www.smarty.net/docs/en/language.function.html.table.tpl *}
{html_table loop=$imgArray cols=2}

 

Link to comment
Share on other sites

3 minutes ago, Dirty Butter said:

I saw some promising looking information when I Googled "how to design a smarty table". But this is WAY past my abilities!! Bsmither will be the one who'll know exactly how to help you.

You cared enough to try

Link to comment
Share on other sites

Currently, that would depend where you want this table to appear.

The topic subject says "Category page", so I conclude you will want to make the data available to Smarty before Smarty renders the "content.category.php" template.

There are two main places where you can add this: in the Catalogue class, the searchCatalogue() function (showing the products in a category is actually a search), and then the displayCategory() function.

In searchCatalogue(), we can use whatever is going on in the search for products (even if it is searching for all products in a given category) to determine what set of images we want to show.

In displayCategory(), we can use whatever is going on with the category itself, its description, and its sub-categories.

 

Link to comment
Share on other sites

Issue overcome by changing consideration - images are too small when displayed in a 2 col table . So I have to show them in 1 col, negating the need to use a table.

But thank you bsmither for your typical willingness to assist.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...