Page 1 of 1

Post entries only on frontpage

Posted: Fri Jul 14, 2006 12:49 pm
by jojje
I want to add one entry from one category on the static page that is set to be frontpage.


A solved this partly with this code in plugin_staticpage-tpl:
Code:
{serendipity_fetchPrintEntries category=1 limit=1 use_hooks=0 template=entries_news.tpl}


Works great except that is is printed on all static pages.

Is there any easy way to solve this, to check if the static page is a frontpage before printing?

Re: Post entries only on frontpage

Posted: Fri Jul 14, 2006 12:55 pm
by garvinhicking
Hi!

You can set up differet Static Page "Types". For each Type you can use a different .tpl file. So just create a new type "Frontpage", then use "plugin_staticpage_frontpage.tpl" for its template.

Then edit your frontpage staticpage. Switch the type to "Frontpage" you just created.

Then create the plugin_staticpage_frontpage.tpl file and only in that file you insert the smarty call. Your other pages will then use an unmodified plugin_staticpage.tpl file. :)

There are also other ways to do this:

1. You could use a check "{if $staticpage_pagetitle ="Title of your frontpage"} ... {/if}

2. Or you could even install and use the smartymarkup plugin, and then not put the smarty code inside your .tpl file, but instead inside the content of your staticpage plugin. :)

Best regards,
Garvin

Posted: Mon Aug 14, 2006 6:34 am
by jojje
Thanx alot for that answer.


But if I want to do this in normal entries, how do I do? I have partly solved this if the entrie is the startpage:

Code: Select all

{if $startpage}
{serendipity_fetchPrintEntries category="3" limit="1" use_hooks="0" template=entries_start.tpl}
{serendipity_fetchPrintEntries category="1" limit="1" use_hooks="0" template=entries_news.tpl}
But how can I do this if the entrie isn´t the startpage? What shall one look for instead of $staticpage_pagetitle?


Probably very easy (newbie) but I can´t find the solution right now.

Posted: Mon Aug 14, 2006 7:01 pm
by garvinhicking
Hi!

Uhm, I don't really understand what you want to do? Could you explain more in depth what you're trying to achieve?

$staticpage_pagetitle is actually the best thing to look for...?!

Best regards,
Garvin

Posted: Mon Aug 14, 2006 9:31 pm
by jojje
Ok, I try to explaine a little better.

What I do right now is that in entries.tpl I check if the selected page is the startpage and if it is so, 2 articles are displayed with 2 different looks/templates. I use this code for that:

Code: Select all

{if $startpage}
{serendipity_fetchPrintEntries category="3" limit="1" use_hooks="0" template=entries_start.tpl}
{serendipity_fetchPrintEntries category="1" limit="1" use_hooks="0" template=entries_news.tpl}
What I want to do is the same but for any other selected page. I have an article named “10-Recepcion.html” witch I want to do the same in. I want to check if the selected page is this page (10-Recepcion.html) and if so, I want to display 2 other articles.

Is it possible in some way to check for id or page title and do the same thing as the code above?

I could use a static page for this but I think would be nice to do it without them. I am making a webpage with 2 languages and has done this with 2 folders for all categories (1 for each language) and has assigned different templates to these categories instead of using the multilingual plugin.

Posted: Tue Aug 15, 2006 6:58 am
by jojje
I tried with

Code: Select all

{if $entry.title != 'Recepcion' }
{serendipity_fetchPrintEntries category="5" limit="1" use_hooks="0" template=entries_start.tpl}
{serendipity_fetchPrintEntries category="4" limit="1" use_hooks="0" template=entries_news.tpl}
{/if}
And it work well when one visits the page "10-Recepcion.html"... but if one visits a category, the same 2 articles are displayed.

I need some other way to do this.

Posted: Tue Aug 15, 2006 7:03 am
by jojje
I think I solved it.... I checked if the page is a single entry and it made it.

Code: Select all

{if $is_single_entry AND $entry.title != 'Recepcion' }
{serendipity_fetchPrintEntries category="5" limit="1" use_hooks="0" template=entries_start.tpl}
{serendipity_fetchPrintEntries category="4" limit="1" use_hooks="0" template=entries_news.tpl}
{/if}
Thx Garvin for taking the time reading all questions I have.

Posted: Tue Aug 15, 2006 10:02 am
by garvinhicking
Hi!

Ah, very great. Sorry for not getting back earlier. But the fix you made is similiar to what I would have suggested. :-)

Best regards,
Garvin

Posted: Wed Aug 16, 2006 10:20 am
by jojje
Do you have any other suggestions how one can do it?


My code works great when I visit 10-Recepcion.html -- > 1 article from category 5 and 1 article from category 4 are printed on the screen
or a category --> all articles in the category is listed.

But when I visit some other article then 10-Rexepcion.html... they also are formated as described above, 1 article from category 5 and 1 article from category 4 are printed.

I am almost thinking of using a static page instead, much easier :P