Jump to content

[solved] Alternative template file doesn't work anymore in latest (or how shoot yourself in the foot)


Recommended Posts

Posted

I use alternative filename on template to use main.php, from where I render the content according to the template name.

So basic-page would result in including the /views/basic-page.inc in the main.php

I now use latest PW on this new site and it doesn't work anymore, as all those end up having a template name "home". When I echo the $page->template it shows "home" no matter what template.

I changed things around and when I use it without alternative filename it works as usual. Can somebody confirm this?

Posted

Just tested this on a new 2.3 install and everything worked normally. Just in case I didn't understand what you mean, this is what I did: went to basic-page template and changed "alternate template filename" to sitemap. Now I have a sitemap in all pages.

  • Like 1
Posted

Thanks diogo, yeah somehow, I just have a main.php and in there echo $page->template outputs "home" always.

It's all very confusing and I can try what I want but no success. It works in other installs though.

I copied this site from one that is very similar and used same template approach. So as a start I copied db and site folder, and dropped in lates wire core.

I'm still trying find what's wrong, but I'm kinda lost.

Posted

Ok once again I have beaten myself... after trying to find a reason, nothing worked I thought it just can't be and knew there must be something stupid like

$page->template = "home"

in the code... and gotcha!

I really should be more careful and always use

"home" == $page->template

Thanks diogo for your time.

  • Like 2
Posted

It's good practice because if you make a mistake and write "=" instead of "==", the first one will give you an error and the second will mess everything by assigning "home" to $page->template without giving any warning.

  • Like 4

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...