View Full Version : Need help on best coding approach
TalkVirginia
08-27-2011, 06:00 AM
I have a mod I'm working on and in a certain place in my script I'm not sure if I should place the html code in a template or keep it in my script.
example:
if ( $someval )
{
$displaytitle = "<a href=\"$link\" class=\"producttitle\" title=\"$title\" style=\"width: $gridcellwidthpx\">$title</a>";
}
/* Render template here */
Does what I'm asking make sense?
In the example above, I'm using the conditionals in the script as opposed to using template conditions to determine if something is displayed.
Which way is better?
nhawk
08-27-2011, 10:21 AM
Either method is correct. The same information gets into a template in either case.
Personally, in most cases I prefer to do it in the code.
BSMedia
08-27-2011, 02:40 PM
I have a mod I'm working on and in a certain place in my script I'm not sure if I should place the html code in a template or keep it in my script.
example:
if ( $someval )
{
$displaytitle = "<a href=\"$link\" class=\"producttitle\" title=\"$title\" style=\"width: $gridcellwidthpx\">$title</a>";
}
/* Render template here */
Does what I'm asking make sense?
In the example above, I'm using the conditionals in the script as opposed to using template conditions to determine if something is displayed.
Which way is better?
Depends i'd suppose. Are you the only one thats going to use this script? Do you anticipate others using it as well?
If you're the only one using it, do whatever is easiest for you. But if you're going to share it, you might as well save yourself the headache and make it simple as possible for the user.
If you're the only one using it, do whatever is easiest for you. But if you're going to share it, you might as well save yourself the headache and make it simple as possible for the user.
I agree - if you're planning to release it here, for instance, I think it's nice to have everything in templates and phrases. Otherwise it doesn't matter so much.
TalkVirginia
08-27-2011, 04:14 PM
Thanks for the tips. I'm working on a Zazzle store front for vb actually. I'm planning on adding phrases and templates. I was having a momentary brain fart I guess. It does make sense to have all the html mark up in the template and just use conditionals to turn things off and on.
:up:
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.