[SOLVED] Variable in content_image parameter

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
chillifish
Forum Members
Forum Members
Posts: 92
Joined: Wed Jul 27, 2011 9:26 am

[SOLVED] Variable in content_image parameter

Post by chillifish »

Looking at the below, it should be pretty obvious what I'm trying to do.

Code: Select all

{content_image block='Image 1' width='490' height='300' dir='/frogmore/pics/galleries/$page_alias'}
I've tried putting the $page_alias variable in double quotes, single quotes, backticks. Is what I'm trying to do even possible?
Last edited by chillifish on Fri Jan 31, 2014 10:21 am, edited 1 time in total.
HarmO
Power Poster
Power Poster
Posts: 251
Joined: Thu Jan 26, 2012 3:22 pm

Re: Variable in content_image parameter

Post by HarmO »

I'm afraid the admin editor does not look at the $page_alias variable the same way as the fronted template does.

BTW: What you try to do would give an error when you create a new page since the page alias is not yet defined at that moment...
Kind regards,
HarmO
chillifish
Forum Members
Forum Members
Posts: 92
Joined: Wed Jul 27, 2011 9:26 am

Re: Variable in content_image parameter

Post by chillifish »

Doh, of course. explains why I'm unable to do it via a UDT as shown below:

Code: Select all

// Use page_alias parameter to define image path
$image_path = "/frogmore/pics/galleries/".$params['page_alias']."/";

// Get image number from paramater
$image_no = "Image ".$params['image_no'];

// Write the smarty
$smarty_data = "{content_image block='".$image_no."' width='490' height='300' dir='".$image_path."'}";
$smarty->display("eval:".$smarty_data);

echo "testing ".$image_path;
I'll have to think of something else.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Variable in content_image parameter

Post by velden »

What are you trying to do?

Maybe we can think of another approach if we know.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Variable in content_image parameter

Post by calguy1000 »

Code: Select all

{content_image block='Image 1' width='490' height='300' dir='/frogmore/pics/galleries/$page_alias'}
Two reasons why this won't work:
a: the page alias is not available in a smarty variable in the editcontent form at all...
b: single quotes are absolute strings.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
chillifish
Forum Members
Forum Members
Posts: 92
Joined: Wed Jul 27, 2011 9:26 am

Re: Variable in content_image parameter

Post by chillifish »

I wanted a an image rotator on each page. I had a script that rotated four images. The plan was that a content editor would be taken to a different folder depending on what page they were editing and could simply select from a dropdown what images they wanted. I've now decided to use another content block that they can put four images in, it means the file browser can be used instead. It's not quite as simple to use, but the content editor is relatively savvy.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Variable in content_image parameter

Post by velden »

Let me post some code I use on one site which adds a tab 'Vier fotos' to the 'edit content' page, let the editor select 4 images (user friendly).
In this example the images are only displayed if all 4 images are selected.

It uses modules: GBFilePicker and CGSmartImage

Code: Select all

{content_module block="filepicker_block_1" module="GBFilePicker" assign="image1" label="Optioneel: afbeelding 1 in rij van 4" mode="browser" media_type="image" dir="images" tab="Vier fotos"}
{content_module block="filepicker_block_2" module="GBFilePicker" assign="image2" label="Optioneel: afbeelding 2 in rij van 4" mode="browser" media_type="image" dir="images" tab="Vier fotos"}
{content_module block="filepicker_block_3" module="GBFilePicker" assign="image3" label="Optioneel: afbeelding 3 in rij van 4" mode="browser" media_type="image" dir="images" tab="Vier fotos"}
{content_module block="filepicker_block_4" module="GBFilePicker" assign="image4" label="Optioneel: afbeelding 4 in rij van 4" mode="browser" media_type="image" dir="images" tab="Vier fotos"}

{if $image1 && $image2 && $image3 && $image4}
   <div class="image-block shadow-box">
     {CGSmartImage src=$image1 filter_croptofit='125,125,,1' noembed=1 alt=""}
     {CGSmartImage src=$image2 filter_croptofit='125,125,,1' noembed=1 alt=""}
     {CGSmartImage src=$image3 filter_croptofit='125,125,,1' noembed=1 alt=""}
     {CGSmartImage src=$image4 filter_croptofit='125,125,,1' noembed=1 alt=""}
   </div>
{/if}
Admin: Edit Content
4images_be_result.jpg
4images_be_browse.jpg
Front end result:
4images_fe_result.jpg
chillifish
Forum Members
Forum Members
Posts: 92
Joined: Wed Jul 27, 2011 9:26 am

Re: Variable in content_image parameter

Post by chillifish »

That's a great help, thanks very much.
Post Reply

Return to “CMSMS Core”