Page 2 of 2

Posted: Mon Aug 21, 2006 11:05 am
by garvinhicking
Hi!

Try this:

Code: Select all

{foreach from=$plugindata item=item}
    <div class="serendipitySideBarItem container_{$item.class}">
    {if $item.title == 'Portfolio Links' AND $category_info.categoryid != '2'}
    <h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2>
    <a href="#">click here to go to our portfolio</a>
    {else}
        {if $item.title != "" }<h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2>{/if}
        <div class="serendipitySideBarContent">{$item.content}</div>
    {/if}
    </div>
{/foreach}
{if $is_raw_mode}
</div>
{/if}
If it works, try to spot the difference :)

Best regards,
Garvin

Posted: Mon Aug 21, 2006 11:59 am
by d_cee
Hi Garvin

didn't work :( I still didn't get the links on the gallery page.

So I came up with this which does work - although it may not be the best way to do it.

Code: Select all

{foreach from=$plugindata item=item} 
    <div class="serendipitySideBarItem container_{$item.class}">
    {if $item.title == 'Portfolio Links' AND $staticpage_pagetitle == 'gallery'}<h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2> 
        <div class="serendipitySideBarContent">{$item.content}</div> 
	{elseif $item.title == 'Portfolio Links' AND $category_info.categoryid != '2' AND $staticpage_pagetitle != 'gallery'} 
    <h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2> 
    <a href="#">click here to go to our portfolio</a> 
    {else}
        {if $item.title != "" }<h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2>{/if} 
        <div class="serendipitySideBarContent">{$item.content}</div> 
    {/if} 
    </div> 
{/foreach} 
{if $is_raw_mode} 
</div> 
{/if}
what do you think?

cheers

Dave

Posted: Mon Aug 21, 2006 12:03 pm
by garvinhicking
Hi!

I'd say that one looks good! :)

It might work to move those two IFs into one IF, but the extra work isn't worth it :)

Best regards,
Garvin

Posted: Mon Aug 21, 2006 5:11 pm
by d_cee
Hi Garvin

I'd like to include more than one gallery. If I call all my pages 'gallery-something' is it possible to only take the first 7 letters of '$staticpage_pagetitle' so that it always returns 'gallery'?

I tried

Code: Select all

{foreach from=$plugindata item=item} 
    <div class="serendipitySideBarItem container_{$item.class}">
    {$gallery = substr($staticpage_pagetitle, 0 , 7)}
    {if $item.title == 'Portfolio Links' AND $sgallery == 'gallery'}<h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2> 
        <div class="serendipitySideBarContent">{$item.content}</div> 
	{elseif $item.title == 'Portfolio Links' AND $category_info.categoryid != '2' AND $gallery != 'gallery'} 
    <h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2> 
    <a href="#">click here to go to our portfolio</a> 
    {else}
        {if $item.title != "" }<h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2>{/if} 
        <div class="serendipitySideBarContent">{$item.content}</div> 
    {/if} 
    </div> 
{/foreach} 
{if $is_raw_mode} 
</div> 
{/if}
but it didn't work of course :-(

Because I'm using this plugin more than once it would be really useful if it could be named (like the sidebar HTML nugget) for identification. Is this possible?

cheers

Dave

Posted: Tue Aug 22, 2006 9:29 pm
by judebert
I think your template didn't work because the substr() call is not a Smarty function. For that, you'll probably want the truncate extension:

Code: Select all

    {$gallery = $staticpage_pagetitle|truncate:7:""}
    {if $item.title == 'Portfolio Links' AND $gallery == 'gallery'}<h2 class="serendipitySideBarTitle

Posted: Tue Aug 22, 2006 10:47 pm
by d_cee
Hey Jude
Thanks a lot, you pointed me in the right direction. I dropped the $gallery and did this instead which works fine

Code: Select all

<div class="serendipitySideBarItem container_{$item.class}">
    {if $item.title == 'Portfolio Links' AND $staticpage_pagetitle|truncate:7 == 'gall...'}<h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2> 
        <div class="serendipitySideBarContent">{$item.content}</div> 
	{elseif $item.title == 'Portfolio Links' AND $category_info.categoryid != '2' AND $staticpage_pagetitle|truncate:7 != 'gall...'} 
    <h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2> 
    <a href="#">click here to go to our portfolio</a> 
    {else}
        {if $item.title != "" }<h2 class="serendipitySideBarTitle {$item.class}">{$item.title}</h2>{/if} 
        <div class="serendipitySideBarContent">{$item.content}</div> 
    {/if} 
    </div>
thanks again
and just by the way do you know the answer to this
Because I'm using this plugin more than once it would be really useful if it could be named (like the sidebar HTML nugget) for identification. Is this possible?
cheers
Dave

Posted: Thu Aug 24, 2006 9:57 pm
by judebert
Glad to hear you got it working!
and just by the way do you know the answer to this
Because I'm using this plugin more than once it would be really useful if it could be named (like the sidebar HTML nugget) for identification. Is this possible?
I was deliberately avoiding that question. :oops:

I know that, if you change the variable "stackable" to "true", you can install multiple copies of a plugin. But if it uses the database for its own settings, you might have multiple versions trying to access (and possibly modify) the same data.

As for adding a name to tell them apart, I'm not so sure. I think you'd need to add another introspection item for the "title". If I were doing it myself -- and I'd love to, but I'm really just too busy these days -- I'd look at the HTML nugget plugin to see how it's done.

Posted: Fri Aug 25, 2006 12:10 pm
by d_cee
Hi judebert
thanks for the reply. I'll give it a try myself - it can only go wrong so what the heck. I'll do what you suggest and take a look at the HTML nugget plugin. So I may be back with more questions :-)

Having read up on Smarty modifiers my truncate now looks for gallery not gall... which I'm pleased about.

thanks for all your help

Dave