Page 1 of 1

SmartImage with Smarty Caching

Posted: Thu Jan 27, 2022 5:35 pm
by andrewvideouk
HI

Can someone help please. :-D I having big problem that SmartImage is not accepiting variables when I enable Smarty Caching. I get this errors.
But if login in the backend everything is working on the site.

Do SmartImage work with Smarty Caching and how much does it make a diffent when turn on Smarty Caching?

Its does say may interfere with the behaviour of some modules.

Thank you


Cheers

Code: Select all

 Could not find a file at: images/staff/ in
/home/backdrop/public_html/modules/SmartImage/action.default.php
on line
44
or no src is set.

This I trying use in LISE

Code: Select all

  
  
  {SmartImage class="rounded-circle"  src1="images/staff/" src2=$item->picture_person alt={$item->title} } 
  and tried
    {SmartImage class="rounded-circle"  src1="images/staff/" src2={$item->picture_person} alt={$item->title} } 
  
  

This I trying use in CGCalendar

Code: Select all

         {if isset($event.fields)}  
    {foreach $event.fields as $fieldname => $fieldrec}
     {if $fieldname == "Image"}
  {assign var="cal_image" value=$fieldrec.field_value}
      {/if}      
         {if $fieldname == "Image description"}
   {assign var="cal_des" value=$fieldrec.field_value}
      {/if}      
    {/foreach}         
{/if}
 {SmartImage src={$cal_image} alt={$cal_des}  filter_croptofit="300,150" } 
/code]

Re: SmartImage with Smarty Caching

Posted: Thu Jan 27, 2022 8:14 pm
by Rolf
Safe yourself a lot of time and headaches: disable Smarty Caching. To get this working like it was designed to, you have to do much more then only enable it in the Admin panel. Several (page) templates need to be changed to stop caching some content. Not worth the fuss, imnsho

Re: SmartImage with Smarty Caching

Posted: Thu Jan 27, 2022 9:10 pm
by rotezecke
I recognise the error message. in my case, not smarty caching related.
SmartImage is very particular about paths.

viewtopic.php?f=7&t=82989

Re: SmartImage with Smarty Caching

Posted: Thu Jan 27, 2022 9:39 pm
by velden
Totally unrelated but I noticed it multiple times.

Don't use the foreach loops to iterate fields in your templates. It's just meant for sample templates because the developer doesn't know which fields you will be defining.

It's like opening every door of your kitchen cabinets every time you need a coffee cup and ask yourself "are the cups here?".
I assume you know where to find the cups so just open that door.

Try something like (untested):

Code: Select all

{SmartImage src=$event.fields['Image'].field_value alt=$event.fields['Image description'].field_value  filter_croptofit="300,150" } 

Re: SmartImage with Smarty Caching

Posted: Thu Jan 27, 2022 9:41 pm
by velden
BTW: there's an assumed bug in SmartImage: http://dev.cmsmadesimple.org/bug/view/12472
Though it seems unrelated to your case.

Re: SmartImage with Smarty Caching

Posted: Fri Jan 28, 2022 11:18 am
by andrewvideouk
Thank you. That's really useful. I hate foreach loops but I didn't really know how to call the variables if they were file uploads and I couldnt work out how to call variables with spaces in them. I will test the code you have given me and disable Smarty Caching if not really needed,

Code: Select all

{SmartImage src=$event.fields['Image'].field_value alt=$event.fields['Image description'].field_value  filter_croptofit="300,150" } 
Without you guys there's no way I could of got this far. I have been making this website for a learning disability group it has taken me a year to make but I have learnt so much. I have a learning disability too so it is hard to learn new things. At the same time I had long nights trying to work how to make codes work on the site. I would like to say a big thank you to you guys and its really appreciated all the help you have given me so far. I am a volunteer for a group and they have no money to pay someone to build a site for them. That's why I said I would help them. Your help goes a long way. Thank you

I am almost there as I need the site to be done by march as they are doing a digital event for people with learning disabilities to get them on the web.