Jump to content

Site Templating Approach


bora
 Share

Recommended Posts

Hi everyone,

I'm starting to code PW side of my first ever PW project. Really excited to see how it goes. :)

While starting out I'm planning a template approach to use in the project mostly relying on wireRenderFile method. As it is my first project I wanted to make sure this won't cause me problems in the long run.

Here is how I started out:

post-3128-0-95514200-1438966982_thumb.pn

I have two functions in _func.php as helpers. One of them is wrapper for wireRenderFile and the other is appender for $content for not using $content .= everywhere

post-3128-0-08736200-1438966978_thumb.pn

I have a global variable called $site. I normally avoid global variables but in this case I'll only have one and its not so different than using $homepage or $title before the includes (or is it??). I'm thinking about making a module for this to keep _init.php clean

post-3128-0-14785200-1438967487_thumb.pn

And in the _main.php my code is like that, with the common areas for pages. For the content of pages, I echo $content for the page content I gathered. For example, for basic-page template file:

post-3128-0-49615900-1438969122_thumb.pn

You can see usage of both functions here.

That's all for the start. I'm trying to keep it simple to prevent going out of my hand.

Do you see any "do not" or "should not" points here, or have any kind of recommendations?

Thanks ahead

  • Like 1
Link to comment
Share on other sites

Thank you Macrura,

I think I should do this for like that? 

//set the data
$config->set('site',$site);

//and reach in templates
$config->get('site');
//OR
$config->site;
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...