Feature Request: Select Sidebar Items Per Template

Creating and modifying plugins.
bdconnolly

Feature Request: Select Sidebar Items Per Template

Post by bdconnolly »

I am using the event_categorytemplates where one can have a unique template per category. Love it; BUT... it just stops a hair short. The ability to choose which sidebar items per template would REALLY make it useful.

How can I do that? Thoughts?

Brian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Feature Request: Select Sidebar Items Per Template

Post by garvinhicking »

You can do that by assigning different templates to a category, then edit that templates sidebar.tpl file and inserting checks like

Code: Select all

{if $is_raw_mode}
<div id="serendipity{$pluginside}SideBar">
{/if}
{foreach from=$plugindata item=item}
    {if $item.class == 'serendipity_categories_plugin' OR $item.class == 'serendipity_plugin_comments'}
    <div class="serendipitySideBarItem container_{$item.class}">
        {if $item.title != ""}<h3 class="serendipitySideBarTitle {$item.class}">{$item.title}</h3>{/if}
        <div class="serendipitySideBarContent">{$item.content}</div>
    </div>
    {/if}
{/foreach}
{if $is_raw_mode}
</div>
{/if}

This will only show the plugins for that category template when the plugin is the "recentcomments" or "categories" plugin.

Yes, this is a bit of manual handwork. But it would be very hard to create an interfacefor these adjustments in the GUI.

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/
bdconnolly

Post by bdconnolly »

Almost. The idea of editing the sidebar.tpl per category works.

BUT...

Let me step back and tell you what I'd like to accomplish: a frontpage like a magazine cover; and then section pages like "Sports, etc." So... on the "Frontpage" I'd really only have article title hyperlinks and no sidebar. Then I'd have unique templates per category with the possibility of unique sidebar items.

I think the major obsticle will be to have articles (as linked on the "frontpage") automatically publish in their respective category template.

See what I am trying to do?

Brian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Basically, if you assign an entry to a single category, it should use the template of that category if you go into full view. Don't know though if that is an option of the categorytemplate plugin, or if it's always enabled...or if it's onlyavailable in 1.0-alpha2 of s9y ...

So I do think you should be able to achieve that all.

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/
Guest

Post by Guest »

Yes and No. Here's where we're getting confused (I think).

Category/template employed, full view per article publishes in the assigned template.

However, to accomplish what I am trying to do I also need to have Start Page Category employed. That then always overrides the category/template full view (except when publishing a category from the sidebar).

So I guess I need help tweaking the Start Page Category. Right?

Brian
Guest

Post by Guest »

How 'bout this: can the contact tag in the index.tpl {$CONTENT}, be limited to a select category?
Guest

Post by Guest »

to be read "content tag" above. Sorry.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

If you move the "category properties" template BELOW your "startcat" plugin, it should catch up on the configured template to use for the frontpage...

You can remove the {$CONTNET} shortcut alltogether by using a Smarty call {serendipity_fetchPrintEntries}, see http://www.s9y.org/78.html.

Even though that's advanced usage, it should all work pretty well once you get familiar with that concept...

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/
Guest

Post by Guest »

moving the event plugin order didnt work for me.

BUT... {serendipity_fetchPrintEntries category="7"}

That worked.

Thanks Garvin!

Brian
bdconnolly

Post by bdconnolly »

DRAT... TACKLED AT THE 1 YARDLINE.

Turns out, that of course the static pages seem to use the frontpage template be default? When trying to create a stark frontpage "cover" like a magazine, that screws things up a bit.

Anyway to configure the static pages to choose a particular template... other than the frontpage default?

Brian
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

Perhaps you'd be better off just editing your frontpage template? You could copy an existing template to a new directory, edit the files to give it a new name, and remove the sidebar from index.tpl. Poof! No sidebar on the front page. Since you've configured stuff so every category uses its own template, you'll get sidebars for all those.

Am I missing something fundamental?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

And of course you can always add a check into your default index.tpl template for a specific check:

Code: Select all

{if $staticpage_pagetitle == 'frontpage'}
...extra stuff here...
{else}
...usual stuff here...
{/if}
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/
bdconnolly

Post by bdconnolly »

Well, so as we're on the same page, here's my game plan so far:

1. make category "Frontpage"
2. install event_categorytemplates
3. create/assign category template(s)
4. edit frontpage template:
4a. nix sidebars, title, footer, ec.
4b. replace {CONTENT} with {serendipity_fetchPrintEntries category="x"} in index

That brings me to the place where all works except that certain staticpages (namely about and contact) use the modified "Frontpage" template by default. Not good.

Okay?

That bring me to Garvin's suggestion. As always, I am confused. Does your suggested code replace 4b above? And, can you give me a hint at "extra stuff here"?

If you have time. This is NOT critical.

Thanks in advance.

Brian
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

No, it does not replace 4b. It's step "4c" actually, you need to do that on top of it all. It might boil down to duplicate template code, but that's only avoidable if you patch up the staticpage plugin to assign a different main template (using $serendipity['template']) if it is called...

"Extra stuff" just means the HTML code you are in need of to format your staticpage like the non-frontpage category.

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/
bdconnolly

Post by bdconnolly »

You lost me Garvin. Sorry. This is a bit beyond my capability.

When (and only if) it is convenient, could you point to an example of "Extra stuff."

Thanks.

Brian
Post Reply