twig best practice regarding template locations [closed] - php

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
My site isn't using a front controller pattern or anything fancy, it's currently a bunch of php files in folders.
e.g:
http://www.example.com/customer/account-settings.php
maps direcctly to:
/var/www/sites/example/http/customer/account-settings.php
I've started playing with twig, and wonder what the best practice for locating the template files is?
Should I put them all in
/var/www/sites/exammple/templates/
or should I put them alongside their corresponding .php file?
/var/www/sites/example/http/customer/account-settings.twig
/var/www/sites/example/http/index.twig
etc?

I would place all files in one directory and than create a configuration variable like
$templatesDir='/var/www/sites/exammple/templates/';
to reference the location.
That way views are organized and not scattered around the project. If for some reason you want to change their location to another directory you just have to change the $templatesDir variable in one place.

Related

Why 2 index.php pages here? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
trying to implement the MCV based off Dary's video
https://www.youtube.com/watch?v=n2yeK6LwSII
I can't understand why we have an index.php in the public folder and index.php in the view/pages folder I honestly can't figure out how the one in the view/pages gets called.
I am trying to configure this on IIS as well
https://github.com/Darynazar/MVCFramework
public/index.php is the entry place of your app.
all other PHP files will include after that, so the index.php in view is not the enry point. you can rename it to whatever you want.

Overriding *.tpl.php in different directory [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
How to override tpl files and keep them in separate sub-directory ? Some templates like core bartik keeps tpl files in template subdir. How to accomplish the same for custom own template ?
You can put all of your templates files (*.tpl.php) in different subdirectories of your choice as long as they are in the "templates" directory of your theme. Drupal will find them without doing anything more, but you may need to flush caches for him to detect the new templates files.

Yii2 advanced structure(need another application like frontend/backend) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I've started recently working with yii2.Using the basic app is easy but what I need to do now is to create an advanced template which has more that frontend and backend.I need it to also have midend and one more compoenent(same as frontend/backend folders).I have been trying to search on the internet but I did not find anything usefull.
I would be grateful if any of you guys can help me out here.
Best regards,
Marius
Copy the backend folder to a new folder, search for "backend" in the project and replace / add a link to the new folder you have created.
There are not so many places, there is one in common/config/bootstrap.php and the rest I believe are in the new "backend" folder. Remember to change the namespaces of controllers / models etc.
I have made this recently, it is easier then you think.

Should Bootstrap handle scripts and styles instead of views? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am working on a distributed project where I saw various "appendStylesheet" and "appendScripts" on headLink which were added in Bootstrap.php.
Honestly, I am not much experienced with ZF (consider few months ~ 2 projects) and personally I think, it is not "semantic". You can always append scripts via layouts or if you want flexibility as per different views, they could be called to appendStyles as every view would want (if not coded in layouts).
My question is about working "collaboratively".
Should "views" related scripts be added on bootstrap or let it do the function of routing and implementing modules, etc?
styles and scripts should be added from the layout or viewscripts. this way you can easily switch the application's "design" from one to another by simply replacing the view and public folders.

separating header and footers into their own files [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
Question: I've read a lot of tutorials/books that have taught putting the header and footers into their own files and using php to include them in the content pages.
However, if you have javascript running in those headers or footers- isn't this "bad" design- or does it not really matter?
I guess I take out the javascript if it's not needed for a page and I don't really mind CTRL+C. However I can see the usefulness and efficiency of making a change in only one file instead of all of them.
You should start using some template engine instead. Something to start with: Twig and Smarty
The most important feature you will like is called Template Inheritance
I would always separate your header and footer files out, it is a nightmare otherwise!
Just load in the JS when you need it, if using PHP just check the $_SERVER vars - http://uk.php.net/manual/en/reserved.variables.server.php

Categories