How do I determine startpage or frontpage?
-
carl_galloway
- Regular
- Posts: 1331
- Joined: Sun Dec 04, 2005 5:43 pm
- Location: Andalucia, Spain
- Contact:
How do I determine startpage or frontpage?
I can't remember where this was last discussed, and my search has been without success so please forgive me for dredging up something that is possibly right in front of my eyes.
A new template I'm working on uses a different startpage (similar to hemingway) and I need to determine if a user has clicked the 'homepage' link or the 'All categories' link.
The difference is that homepage is just the base URL, whereas the all categories link adds ?frontpage to the url. I've tried using {$smarty.get} but printing the result only produces the word 'array' for both instances, so obviously this isn't the right approach. Can anyone suggest anything else? Should I be adding something to config.inc.php
Carl
A new template I'm working on uses a different startpage (similar to hemingway) and I need to determine if a user has clicked the 'homepage' link or the 'All categories' link.
The difference is that homepage is just the base URL, whereas the all categories link adds ?frontpage to the url. I've tried using {$smarty.get} but printing the result only produces the word 'array' for both instances, so obviously this isn't the right approach. Can anyone suggest anything else? Should I be adding something to config.inc.php
Carl
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How do I determine startpage or frontpage?
Hi!
Maybe {$smarty.get.frontpage} does the trick?
(Yeah, I'm terribly short on time and sick once again, so I hope my bare words make some sense)
HTH,
Garvin
Maybe {$smarty.get.frontpage} does the trick?
(Yeah, I'm terribly short on time and sick once again, so I hope my bare words make some sense)
HTH,
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/
# 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/
-
carl_galloway
- Regular
- Posts: 1331
- Joined: Sun Dec 04, 2005 5:43 pm
- Location: Andalucia, Spain
- Contact:
-
carl_galloway
- Regular
- Posts: 1331
- Joined: Sun Dec 04, 2005 5:43 pm
- Location: Andalucia, Spain
- Contact:
-
stm999999999
- Regular
- Posts: 1531
- Joined: Tue Mar 07, 2006 11:25 pm
- Location: Berlin, Germany
- Contact:
in my individual template
in index.tpl
helps to find the static startpage
and in entries.tpl I have
in index.tpl
Code: Select all
{if $startpage}
and in entries.tpl I have
Code: Select all
{if ($view == 'archives') || ($view == 'frontpage')}
{/if}
{if ($view == 'categories')}
{/if}
{if ($view == 'entry')}
{/if}
Ciao, Stephan
-
carl_galloway
- Regular
- Posts: 1331
- Joined: Sun Dec 04, 2005 5:43 pm
- Location: Andalucia, Spain
- Contact:
STM999999999, sorry that didn't work either.
Let me rephrase my problem. I've got some smarty that checks to see if the user is on the startpage, and when they are, they are redirected to a new .tpl file called entries_startpage.tpl, and on this page the user only sees the first entry body in full, all other entries only show the entry title.
This is different from the normal entries.tpl which shows the bodies of all entries.
What I want to do is provide a browse function in the template so if the user clicks the 'all categories' link in the categories plugin, or the browse all entries link that I will provide, I want the user to be directed to entries.tpl instead of entries.startpage.tpl.
It should be possible to do this since the URL of the homepage and the all categories page are different, because of the ?frontpage. I've tried using every combination of {$smarty.get} and nothing seems to let me check to see if ?frontpage is part of the url or not. I NEED to know if ?frontpage is part of the url because both links (homepage or ?frontpage) activate the $view == start
I guess I could edit index.php, but this would only work on my local installation, and I plan to make this template available for download so all users of Serendipity would need to be able to use my new template without having to edit any of the core files.
Let me rephrase my problem. I've got some smarty that checks to see if the user is on the startpage, and when they are, they are redirected to a new .tpl file called entries_startpage.tpl, and on this page the user only sees the first entry body in full, all other entries only show the entry title.
This is different from the normal entries.tpl which shows the bodies of all entries.
What I want to do is provide a browse function in the template so if the user clicks the 'all categories' link in the categories plugin, or the browse all entries link that I will provide, I want the user to be directed to entries.tpl instead of entries.startpage.tpl.
It should be possible to do this since the URL of the homepage and the all categories page are different, because of the ?frontpage. I've tried using every combination of {$smarty.get} and nothing seems to let me check to see if ?frontpage is part of the url or not. I NEED to know if ?frontpage is part of the url because both links (homepage or ?frontpage) activate the $view == start
I guess I could edit index.php, but this would only work on my local installation, and I plan to make this template available for download so all users of Serendipity would need to be able to use my new template without having to edit any of the core files.
-
mgroeninger
- Regular
- Posts: 546
- Joined: Mon Dec 20, 2004 11:57 pm
- Contact:
You could do some like this in config.inc.php:
I think that should work (but I can't test it at the moment...) Unfortunately, I'm not sure how to do it nicely in serendipity...
Code: Select all
if(isset($_POST['frontpage'])) $serendipity['smarty']->assign_by_ref('frontpage',true); Matthew (Feeling generous?)
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Try this in your template:
this should give you a verbose array display of how the variable looks like. You might need to set $serendipity['smarty']->security=false in your templates config.inc.php to use the "print_r" modifier.
Then check how the output is using different URLs?
HTH,
Garvin
Try this in your template:
Code: Select all
<pre>{$smarty.get|@print_r}</pre>
Then check how the output is using different URLs?
HTH,
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/
# 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/
-
carl_galloway
- Regular
- Posts: 1331
- Joined: Sun Dec 04, 2005 5:43 pm
- Location: Andalucia, Spain
- Contact:
Oh thats interesting!
The basic homepage displays this;
the all categories link produces this
BTW, ignore the 'serendipity0.91' part of the subpage url, I am actually running v1.1 beta5.
So it looks like the ?frontpage part of the url does get recognised by Serendipity and the url is put into the [subpage] part of the array, and also a new variable [frontpage] is added, but why is it empty? Is this a bug in s9y, or is this intentional.
Assuming everything is working as it should, I guess I need to figure out some way of checking to see if {$serendipity_subpage} includes the text ?frontpage within the string. Oh man, this is beyond my smarty knowledge, any ideas?
Edit: I've tried accessing {$serendipity_subpage} in index.tpl and nothing happens.
The basic homepage displays this;
Code: Select all
Array
(
[serendipity] => Array
(
[action] =>
[adminAction] =>
[subpage] => /serendipity0.91/
[page] => 1
)
)
1
Code: Select all
Array
(
[frontpage] =>
[serendipity] => Array
(
[action] =>
[adminAction] =>
[subpage] => /serendipity0.91/index.php?frontpage
[page] => 1
)
)
1
So it looks like the ?frontpage part of the url does get recognised by Serendipity and the url is put into the [subpage] part of the array, and also a new variable [frontpage] is added, but why is it empty? Is this a bug in s9y, or is this intentional.
Assuming everything is working as it should, I guess I need to figure out some way of checking to see if {$serendipity_subpage} includes the text ?frontpage within the string. Oh man, this is beyond my smarty knowledge, any ideas?
Edit: I've tried accessing {$serendipity_subpage} in index.tpl and nothing happens.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
# 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/
# 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/
-
carl_galloway
- Regular
- Posts: 1331
- Joined: Sun Dec 04, 2005 5:43 pm
- Location: Andalucia, Spain
- Contact: