staticpages plug + mod_rewrite for frontpage problem

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
robi-bobi
Regular
Posts: 40
Joined: Mon Nov 21, 2005 12:40 pm
Location: Bulgaria
Contact:

staticpages plug + mod_rewrite for frontpage problem

Post by robi-bobi »

Hello

I am using staticpages plugin
I have changed the default page to show one of the static pages and not recent posts

In order to show the previous default page I can call it via: index.php/frontpage

this all works

What I would like is to have custom "permalink" for that URL
so I entered in menu: /posts/html and I added :

Code: Select all

#frontpage rule
RewriteRule ^posts\.html /index.php?frontpage
at the start of my .htaccess

this also works

the problem is that link at the bottom of frontpage which links to second page of posts instead of:
http://blog.robi-bobi.net/archives/P2.html
has been automatically changed to:
http://blog.robi-bobi.net/posts/P2.html
which is no good :)
(it may be that some other links have that behaviour)

Is this expected ?
And how can I have custom permalink for frontend

thank you



P.S.
is there a list of all available functions and variables (I have not found such at tech doc links at the left sidebar of s9y.org site)
I am about to create custom homepage and I would like to have a view of what is already there, so I could reuse existing functions

what I might need:
get_latest_entries(5);
get_most_commented_entries(3);
etc


P.P.S
i found this page:
http://www.s9y.org/78.html
so this is how I managed to fetch what I needed:

Code: Select all

LATEST ENTRIES:
 {serendipity_fetchPrintEntries limit="3"}
 <br/>
Most commented entries:
 {serendipity_fetchPrintEntries limit="3" orderby="comments DESC"}
I suppose that if I want to print only titles of entries and link to them, I should use the parameter:

Code: Select all

template:          
(string)  
Name of the template file to print entries with
or there is another way which I don't see right now


P.P.P.S. (rofl)
consider creating some similar pages:
http://www.scottklarr.com/topic/100/php-cheat-sheets/
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: staticpages plug + mod_rewrite for frontpage problem

Post by garvinhicking »

Hi!

Serendipity uses the $_SERVER['REQUEST_URI'] string to perform "next page" and some other URLs. If you use custom redirection, the REQUEST_URI remains. You couuld patch include/functions_permalinks.inc.php, the serendpity_getUriArguments() function by replacing:

Code: Select all

   if (strlen($_res[2]) != 0) {
        $args = explode('/', $_res[2]);
        if ($args[0] == $indexFile || $args[0] == $serendipity['indexFile']) {
            unset($args[0]);
        }
        return $args;
with:

Code: Select all

   if (strlen($_res[2]) != 0) {
        $args = explode('/', $_res[2]);
        if (count($args) == 1 && stristr($uri, '.html')) {
            return array();
        }
        if ($args[0] == $indexFile || $args[0] == $serendipity['indexFile']) {
            unset($args[0]);
        }
        return $args;
But then, you will also have the default s9y blog view and not your overview. :)

So you'd most probably to a HTTP 301 redirect in your htaccess:

Code: Select all

RewriteRule ^posts\.html /index.php?frontpage [L,QSA,R=301]
This will then show the URL in your browser bar, but I know no other solution that would not break the whole s9y permalink system.
P.S.
is there a list of all available functions and variables (I have not found such at tech doc links at the left sidebar of s9y.org site)
We have this:

http://www.s9y.org/102.html
http://www.s9y.org/78.html
what I might need:
get_latest_entries(5);
get_most_commented_entries(3);
etc
We have a smarty serendipity_fetchPrintEntries() function that can print entries. To get most commented ones, you need to use manual SQL.
I suppose that if I want to print only titles of entries and link to them, I should use the parameter:

Code: Select all

template:          [/quote]

Yes, exactly, this is the way to go in this case.

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/
robi-bobi
Regular
Posts: 40
Joined: Mon Nov 21, 2005 12:40 pm
Location: Bulgaria
Contact:

Post by robi-bobi »

great
I am not sure the 301 status is good for SEO, and SEO is why I want separate URLs for homepage and 'recent posts' page
if I come to some conclusion, I will write here

is there a way to override whole index.tpl for custom static page and not only the entries part with custom tpl

if not clear, here is an example: I want the sidebars gone in my overview page :)

I can add this page to the list, too:
http://www.s9y.org/43.html
(for future readers)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
if not clear, here is an example: I want the sidebars gone in my overview page :)
You can do that via editing index.tpl, at the place where {serendipity_printSidebar} is called you can add a check:

Code: Select all

{if $view != 'start' && $view != 'plugin'}
{serendipity_printSidebar...}
{/if}
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/
robi-bobi
Regular
Posts: 40
Joined: Mon Nov 21, 2005 12:40 pm
Location: Bulgaria
Contact:

Post by robi-bobi »

cool

I actually assigned one var in my custom.tpl and then make
{if $show_sidebars != 'false' }
in index.tpl
robi-bobi
Regular
Posts: 40
Joined: Mon Nov 21, 2005 12:40 pm
Location: Bulgaria
Contact:

Post by robi-bobi »

snippet from my template for customized homepage, showing latest entries and most commented entries from last month

if someone needs it, here it is:

Code: Select all

<div id="latest_posts">
                    <div class="one_box">
                        <h4 class="summary_title">Latest entries</h4>
                        {serendipity_fetchPrintEntries limit="5" template="entries_links.tpl" skip_smarty_hooks="true"}
                    </div>

                    <div class="one_box">
                        <h4 class="summary_title">Most commented last month</h4>
                        {serendipity_fetchPrintEntries limit="5" orderby="comments DESC, e.timestamp DESC" template="entries_links.tpl" skip_smarty_hooks="true" filter_sql="e.timestamp > UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH)) AND comments > 0"}
                    </div>
                </div>
my entries_links.tpl is very simple one:

Code: Select all

<!-- ENTRIES LINKS START -->
    {foreach from=$entries item="dategroup"}
	{foreach from=$dategroup.entries item="entry"}
		<a href="{$entry.link}" class="entries_links">{$entry.title}</a>
        {/foreach}
    {/foreach}
<!-- ENTRIES LINKS END -->
now, time to fight with that pretty URL problem for which the topic is originally written :)
robi-bobi
Regular
Posts: 40
Joined: Mon Nov 21, 2005 12:40 pm
Location: Bulgaria
Contact:

Post by robi-bobi »

hm, strange problem

i have following setup (latest SVN):
staticpage set as homepage
blog language is set to bulgarian
this works

but when I set my User language to english
the homepage is reverted to list of posts when viewed with my user :)

no big deal, just to let you know
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Did you set the language of your staticpage to something other than "Default"? If you set it to bulgarian, the page only shows up for bulgarian users. You either need to create an english static page, or make the current staticpage not language-associated.

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/
robi-bobi
Regular
Posts: 40
Joined: Mon Nov 21, 2005 12:40 pm
Location: Bulgaria
Contact:

Post by robi-bobi »

yep, that was the case
thanks
Post Reply