tabbed yahoo-like block

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
Krzyzak
Regular
Posts: 41
Joined: Mon Oct 16, 2006 1:13 pm

tabbed yahoo-like block

Post 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
Sorry for my language errors- It`s not my native language.
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: tabbed yahoo-like block

Post 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
Krzyzak
Regular
Posts: 41
Joined: Mon Oct 16, 2006 1:13 pm

Post 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
Sorry for my language errors- It`s not my native language.
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Post 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
Krzyzak
Regular
Posts: 41
Joined: Mon Oct 16, 2006 1:13 pm

Post 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 ? :)
Sorry for my language errors- It`s not my native language.
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Post 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
=Don=
Krzyzak
Regular
Posts: 41
Joined: Mon Oct 16, 2006 1:13 pm

Post 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}
Sorry for my language errors- It`s not my native language.
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

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

Post 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
# 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/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

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

Post by garvinhicking »

Hi Don!

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

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/
Don Chambers
Regular
Posts: 3657
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

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

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