PDA

View Full Version : A Suggestion From A Developer To a Developer


HIddenPanda
01-23-2011, 01:38 PM
Take This:
// ************************************************** ********************
// Begin Template Definition
// ************************************************** ********************

//Define our current theme
$file = $themeurl;

// Do the template changes and echo the ready template
$template = file_get_contents($file);

$template = replace(':ARTICLETITLE:',$article_title,$template) ;
$template = replace(':ARTICLECONTENT:',$article_content,$templ ate);
$template = replace(':ARTICLEDATE:',$article_date,$template);

$template = replace(':BROWSERTITLE:',$browsertitle,$template);
$template = replace(':SITENAME:',$sitename,$template);

//Define our links

if($cancp == "yes"){

//Admins see a custom set of links here...

$links = getadmlinks();

}
else{

$links = getlinks();

}

$template = replace(':LINKSBAR:',$links,$template);

//Get the content for the side bar...

$sidebar = getsidebar();
$template = replace(':SIDEFEED:',$sidebar,$template);

//Get the ad content...
$template = replace(':ADS:',$ads,$template);

//Get the slogan info
$template = replace(':SLOGAN:',$slogan,$template);


echo $template;

// ************************************************** ********************
// End Template Definition
// ************************************************** ********************And Put it into a file called inc\templatedefn.php

So that way instead of the above in EVERY SINGLE FILE... we just have:
include('inc\tempdefn.php');at the end of the file :D

This is mainly directed towards HoF and the other Dev Staff

This also makes it alot easier for people who want to add elements to their pages

Hall of Famer
01-23-2011, 01:53 PM
Thank you for your suggestion. Arianna has been doing this kind of stuff for the next release Mys v1.2.0, as you will soon see.

HIddenPanda
01-23-2011, 01:58 PM
Cool, I just remembered it from when I wanted to write a little news ticker mod but didn't want to make all of the people who wanted to install it go through every single page to insert one little line of code. This way you just add it to this page and the actual template and voila :D

Tequila
01-23-2011, 07:13 PM
Ooh, I'll see if that makes my problems go away. :)

A news ticker wouldn't be that difficult to add I think.

I've done it in templates with little problems.