PHP - Moved: Html Template?
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=347856.0 Similar TutorialsThis topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=317600.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=321218.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=349834.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=359002.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=315539.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=358619.0 This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=316401.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=315590.0 Hi.
I have an HTML template that I'm going to use for my CMS, and need some advice on the best way to split it up into common elements used across all pages.
I've identified the common HTML and have written functions to include each. I've used functions instead of directly including them on the page for flexibility in the future.(wise?)
/* functions.php */ function show_style() { include_once 'module-style.php'; } function show_header() { include_once 'module-header.php'; } function show_sidebar() { include_once 'module-sidebar.php'; } function show_footer() { include_once 'module-footer.php'; } function show_js() { include_once 'module-js.php'; }And then on the page itself... <?php include_once 'functions.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <title>My CMS</title> <meta charset="utf-8"> <?show_style()?> </head> <body> <?show_header()?> <!-- start section content--> <section class="section-content"> <?show_sidebar()?> <!-- start content --> <div class="content"> // PAGE CONTENT </div><!--/ end content --> </section> <!-- /end section content--> <?show_footer()?> <?show_js()?> </body> </html>A few questions - are there any issues with using the <? tag as opposed to <?php.... I've seen it used in templating before and want this to be as clean and readable as possible. Also would it be better to use a class for this, and include all of my functions within that class? Any advice or alternatives on the method used above would be great Edited by paddy_fields, 16 October 2014 - 03:50 AM. I am trying to make a site with content in databases and using some template html files for the layout. The problem I am having is that the code is executing in the template directory and can't therefore read the value from any $_GET that is on the url used by the user. I hope you can understand my meaning. Let me give an example of the structure.. The user visits "www.example.com/search.php?q=something" The file "search .php" just contains a function call to display the page; e.g. DisplayPage("search"); The DisplayPage function uses CURL to read the contents of a HTML file (/templates/search-template.htm) into a string. It then uses preg_replace and str_replace to replace some markers that are in the template, with data from the database. At the end of the function it simply echoes the string. The template files contain some includes, which work fine, but the code executing within them "thinks" it is being executed from /templates/search-template.htm rather than /search.php. Therefore if I use $_GET['q'] in any of those includes, it is empty. I hope that makes sense! Is there any way for me to make the executing code work as if it is being executed from "/search.php" rather than the template? This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=307587.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=343133.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=328435.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=347457.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=351491.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=317537.0 This topic has been moved to Website Critique. http://www.phpfreaks.com/forums/index.php?topic=355553.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=308636.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=345218.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=343705.0 |