bug in index.php, $view variable, archives and 404

Found a bug? Tell us!!
Post Reply
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

bug in index.php, $view variable, archives and 404

Post by carl_galloway »

Hi everyone,

I've been playing around with the $view variable in templates and I've discovered a couple of bugs.

Archives: index.php assigns $view 'archives' to both the overview page and the archives pages. Overview pages are handled by entries.tpl and archive pages are called by the $ARCHIVES variable in content.tpl. So both are different from each other, with different smarty template files, and even different permalinks (archive vs archives) yet both are assigned $view == archives. Can I suggest that in index.php that the actual archives page are assigned $view == archive, and that overview pages are assigned $view == archives? This will allow proper use of $view in template files.

404: I've noticed that an obviously incorrect url such as badly spelling a permalink (try archiv instead of archive) will set $view == 404, and this allows template designers to setup a custom 404.tpl file. However, a badly formed entry url doesn't generate a 404, instead it is handled in entries.tpl by the {foreachelse}no entries to print{/foreach}. Try changing the entry id part of an entry url to a number that does not exist (ie the entry has been deleted or has not been written yet). Surely this should generate a 404 as well. Are we able to look into this?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: bug in index.php, $view variable, archives and 404

Post by garvinhicking »

Hi Carl!

You are right about the archives! this was just a typo, in the second case it should really read 'archive'. I just committed a change.

The second thing, I currently see no solution without breaking all templates and plugins that listen on custom permalinks. The problem is that the place wher ethe "No entries to print" is emitted is already much too late - the template has already been called, the printEntries() routine already executed on the result of a permalink search. Thus, at that point s9y knows that a "valid" link is called that it passes on to plugins and itself and expects an $entries array at that point...

Best 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/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Hi Garvin, thanks for fixing the archive/archives thing. I've seen how much work you've done on v1.1 and typos like these are easy to miss.

As for the 404, I understand, in the template I'm working on right now I've done this;

Code: Select all

    {foreachelse}
    {if not $plugin_clean_page}
        {include file="404.tpl"}	
    {/if}
    {/foreach}
instead of 'no entries to print', and it seem to work for my purpose. Is there any way the 404 error handling can be improved in the future, especially because s9y actually uses apache error handling for a lot of users?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Carl!

I currently see no way to use the usual 404 routine at that point. Much of the logic would be changed and would introduce a loss of flexibility in some cases....so, what I'm trying to say: Don't hold your breath for that change - it is a very hard BC-problem.

Best 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