External PHP Application

Creating and modifying plugins.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post 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
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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
Judebert
---
Website | Wishlist | PayPal
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post 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
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post 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.
Judebert
---
Website | Wishlist | PayPal
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post 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
Post Reply