Page 1 of 1

tabbed yahoo-like block

Posted: Tue Aug 26, 2008 12:20 am
by Krzyzak
Hi.
I would like to create yahoo.com - like tabbed block (for example:
Featured
Entertainment
Sports
Video
)
Is some block available with this feature?
If not, how can I create something like this? I mean how to create html markup - I can create js tabs, but I'm currently unable to create block with few categories


Sorry for my language errors - english isn't my native language

Re: tabbed yahoo-like block

Posted: Tue Aug 26, 2008 1:17 pm
by yellowled
Krzyzak wrote:I would like to create yahoo.com - like tabbed block
Is some block available with this feature?
I'm not sure which part of yahoo.com you want to create exactly, but if you're looking for a s9y theme with a customizable navigation bar (which can also consist of horizontal tabs), you might want to check out Bulletproof.

Otherwise, I need more input :)

YL

Posted: Tue Aug 26, 2008 9:37 pm
by Krzyzak
well, look at the top of yahoo.com - there's block with news - categories: (News World Local Finance) - I would like to create something like this.
Or, maybe other way to explain, what I want to do:
I would like to have on main page -let's say- 5 news for each categories, which I'll display in one tabbed-block
Here's some screen with block, which I would like to create

Posted: Tue Aug 26, 2008 11:37 pm
by yellowled
Krzyzak wrote:I would like to have on main page -let's say- 5 news for each categories, which I'll display in one tabbed-block
Here's some screen with block, which I would like to create
Phew. Now, that's a tad more complicated since you want "real" tabs (at least I assume you want "real" tabs).

The tabs part isn't even that hard to do - you're probably going to want Javascript for that. Personally, I like this tabber script, but there are more solutions out there. But since your "original" is by yahoo, maybe there is some code for that in the Yahoo UI ..?

The hard part is to get the content you want to display, and I'm still not sure what that would be ... something like the 5 recent entries for each category?

YL

Posted: Wed Aug 27, 2008 12:05 am
by Krzyzak
The hard part is to get the content you want to display, and I'm still not sure what that would be ... something like the 5 recent entries for each category?
exactly. I can create js markup, however - I need html with entries.
So, how can I get 5 entries for each category on main page ? :)

Posted: Wed Aug 27, 2008 12:17 am
by Don Chambers
There are a lot of tabbing scripts out there that degrade gracefully when a visitor does not have javascript. Tabber, as Yellowled mentioned, is a good one. I used jquery to do a site quite some time ago... ultimately, the site has not really achieved its original objective, but you can see it here: http://www.blogs.showbuzzonline.com/

As an example, to retrieve the 5 most recent entries for a category #25, using a custom smarty template called "entries_custom.tpl", you can use code such as this in index.tpl:

Code: Select all

{serendipity_fetchPrintEntries limit="0,5" category="25"  template="entries_custom.tpl"}
More information on serendipity_fetchPrintEntries can be found here: http://www.s9y.org/78.html

Posted: Wed Aug 27, 2008 12:51 am
by Krzyzak
As an example, to retrieve the 5 most recent entries for a category #25, using a custom smarty template called "entries_custom.tpl", you can use code such as this in index.tpl:
Code:
{serendipity_fetchPrintEntries limit="0,5" category="25" template="entries_custom.tpl"}
that's what I was looking for, thanks!
Now, I've got another problem: how to use this code only on home page? So, I would like to have this tabbed block on home page, but when I'll click on article link, then I'll see it's content?
I mean something like this to index.tpl:

Code: Select all

{if $is_home_page}
{$CONTENT}
{/if}
{else}
{serendipity_fetchPrintEntries limit="0,5" category="25"  template="entries_custom.tpl"}
{/if}

Posted: Wed Aug 27, 2008 5:09 am
by Don Chambers
Your request becomes a bit more complicated - but not impossible!! :)

2 guys - whom I sincerely respect - and I came up with a template named "Bulletproof". In that template, we use a technique to detect the true frontpage of a serendipity install (the code of which I think was actually provided by another great guy named Abdussamad)....

A template can have a file named config.inc.php.. in the bulletproof template we have this code:

Code: Select all

$serendipity['smarty']->assign(array('currpage'=> "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']));
I STRONGLY encourage you to look at all the code for that template. But this one line is setting a template variable named $currpage.

While we are not doing this in Bulletproof, we can, in index.tpl, evaluate whether this $currpage variable is the same as the URL that you have specified for your site:

Code: Select all

{if $currpage==$serendipityBaseURL}
This gives us a condition for determining if the page a visitor is viewing is actually the "frontpage", and if so, emit our desired code. Give that a try and let us know how it works out.

Note specifically to Garvin: we have a smarty $view variable for "start", but it applies to more than the true frontpage. This smarty variable will also apply to the contact form, static pages, and who knows what else. I think we could use a smarty variable for the true frontpage. Let me know if we can do this for 1.4.

Posted: Wed Aug 27, 2008 10:39 am
by garvinhicking
Hi!
Note specifically to Garvin: we have a smarty $view variable for "start", but it applies to more than the true frontpage. This smarty variable will also apply to the contact form, static pages, and who knows what else. I think we could use a smarty variable for the true frontpage. Let me know if we can do this for 1.4.
I'm not sure if this can be done without changing every plugin. I believe you might need to use {if $view == 'start' AND $staticpage_pagetitle == ''} to deduce the real startpage? This works at least with plugins that set this $staticpage_pagetitle variable...

Regard,s
Garvin

Posted: Wed Aug 27, 2008 3:44 pm
by Don Chambers
Thanks Garvin - if that condition works for determining the frontpage, great. My intent was not to change every plugin, just possibly introduce a new smarty var that templates could use going forward.... but again, if the code you mention already does that, then there is no reason to introduce something new.

Posted: Wed Aug 27, 2008 4:11 pm
by garvinhicking
Hi Don!

I'm not 100% sure if it works. But I have high hopes that it could. ;)

Regards,
Garvin

Posted: Sat Jan 24, 2009 3:28 am
by Don Chambers
garvinhicking wrote:I believe you might need to use {if $view == 'start' AND $staticpage_pagetitle == ''} to deduce the real startpage? This works at least with plugins that set this $staticpage_pagetitle variable...

Regards,
Garvin
Just tripped across a plugin that this does NOT work for....

The permalink plugin does not change $view to 'entry'. Can that be easily corrected?

Posted: Mon Jan 26, 2009 11:29 am
by garvinhicking
Hi!

Hm, but the PHP code of that plugin does set $serendipity['view'] = 'entry' inside the code, so I don't really understand...you do call the permalink URL in that case?

Regards,
Garvin