23379 Posts in 18298 Topics by 2867 members
|Go to End|
18 April 2009 at 5:03am
I see in the BlackCandy Page.php file we have a line:
// Note: you should use <% require %> tags inside your templates instead of putting Requirements calls here. However
// these are included so that our older themes still work
I am wondering why it is better to require the files inside the templates rather than the code file. By my logic I would rather keep that sort of thing out of the template file to simplify things for the person who works on the styling and layout since I pretty much program the site and another person styles it.
I also set things up so that things are very easy for the end user of the CMS interface. I usually make the smallest amount of page types that I can so that the end user isn't confused by a huge list of page types. I make a lot of decisions based on what the parent type of a page is rather than making holders and such. If I want all the child pages of a landing page to inherit the parents Header Image for example I don't make a special page type for the holder and child pages I just set the header style as a parameter in the landing page and all the normal page types that happen to be a child of that one automatically take the header style from the parent. That way all the end user has to do is create a new page and depending on variables that the landing page has they will be conformed to what I want them to be. This way a user can just create new "Page" and never have to worry about new "NewsHolder" or "NewsPage" and such. There are of course times when the page type is too complex for this as is the case for example, a "Blog" page.
18 April 2009 at 6:18pm
Well SilverStripe supports both as there are times where you want to include CSS and you don't want a custom template so doing it via the PHP is a very good idea, other times if you have a custom template Page_blah.ss and no blah method you would have to write a function blah() just to include a stylesheet where as you can just have 1 line in the template. A template option gives extra flexibility to the developer without reverting to <link> tages
I personally stick to the PHP option but each to their own.
21 April 2009 at 5:18am
If the module writer chose to use Requirements calls, I'm forced to change the module php files in order to change my "view". It also makes module updates quite cumbersome.
Just my 2 cents on this.
21 April 2009 at 8:57am
Thanks for sharing your perspectives on this. I will now have to mull it over and decide what I want to do. I like the control I have in php and how it puts things in an expected order. If I mix the php with the template sometimes things don't load in the order I want them. So I also think that seeing CSS as part of the view and putting them all in the template is a good idea as far as controlling the order goes as well.
Hmmmm. Gonna have to think on it some more.
13 July 2009 at 5:38am
This is quite confusing really. There's got to be a way to put them in the templates & still retain the order that you want. If you do it the suggested way & keep the view in the templates only then the conditional comments are out of order & that seems to defeat the point of using them at all. But I do agree that the view should be in the templates. However, it's got to work & that takes priority over code best practices in my opinion.
|Go to Top|