Jump to content
MakeWebGames

What's a good way to setup a game with multiple layouts?


Recommended Posts

does the user pick or per page?

Right now they can choose between two layouts by going to two different folders on my server, but I'd rather have their choice stored in the db for example. Having two folders requires me to have a lot of similar files between the two (altough the two share certain files).

Link to comment
Share on other sites

Depends, if you use the MVC you could just have 2 views, then depending on the choice of the user change a constant which chooses which folder to choose. If that makes sense?

Link to comment
Share on other sites

Depends, if you use the MVC you could just have 2 views, then depending on the choice of the user change a constant which chooses which folder to choose. If that makes sense?

I haven't read a lot about MVC yet, but I guess that's one of the options. Do you use it?

Link to comment
Share on other sites

Try use the template engine Twig http://twig.sensiolabs.org/

It support inheritance (which you technically are looking for to make templating so easy and nice!), automatic escaping (makes protecting against XSS a piece of cake).... Nice syntax, secure, flexible (you can create functions/helpers to use in your templates) and so on.

How would twig help with multiple templates? Didn't think it could? :s

 

I haven't read a lot about MVC yet, but I guess that's one of the options. Do you use it?

Yes I do.

Link to comment
Share on other sites

How would twig help with multiple templates? Didn't think it could? :s

 

Yes I do.

 

Have a variable defining a layout.

$layout = 'default'.

//render

$twig->render($layout . '/index.twig', $data);

 

Now in your templates/ folder you have folders for each "layout"

default/

...index.twig.

admin/

...index.twig.

purplepink/

...index.twig.

...

Link to comment
Share on other sites

Have a variable defining a layout.

$layout = 'default'.

//render

$twig->render($layout . '/index.twig', $data);

 

Now in your templates/ folder you have folders for each "layout"

default/

...index.twig.

admin/

...index.twig.

purplepink/

...index.twig.

...

Oh ok, I thought you insinuated twig had a built in method

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...