Log in

View Full Version : A little issue, hard to find a title for...



alexjewell
07-25-2006, 02:24 AM
I'm working on a weblog of mine, and I had this cool idea...
There's a lot of repeat code, so I decided to do this:



$thetitle = "
<div class=\"content\">
<div id=\"".$the_title."\"><h1>".$mrtitle."</h1></div>
<div class=\"cont\">
<div class=\"cont-container\">";

$thetitle2 = "
<div class=\"content\">
<div id=\"".$the_title2."\"><h1>".$mrtitle2."</h1></div>
<div class=\"cont\">
<div class=\"cont-container\">";

Then, when it came up:



if ($page == "about") {
$the_title = "us";
$the_title2 = "me";
$mrtitle = "About Us";
$mrtitle2 = "About Me";

echo "

$thetitle"."

<p>We're a branch of Flame Html Studios, a web design firm based in Cleveland, Ohio. This blog exists to
inform the public of interesting, helpful, entertaining, and practical topics relating to such things
as art, web design, programming, Faith, etc.</p>

<p>We strongly believe in the web standards set out by the W3C, and we strive to create out sites more
simple in every new design, idea, and line code that we spit out.</p>

"."$titlebot"."
$thetitle2"."

<p>My name is Alex Jewell. I'm a web designer, photographer, writer, artist, musician, and strong
Christian. As the founder and only designer, at this point, of Flame Html Studios, I learn more in the
realm of technology and design everyday. This blog is you learning what I do as I do.</p>

<p>I'm 14. I'm rad. I'm a geek. I love music. I love life. I love writing. I love design. Enjoy this
little project.</p>

"."$titlebot";}

See, this way I was making life a million times easier by stating what $the_title and $the_title2 were equal to later when I needed to, you know?

But this is throwing errors, saying they're undefined variables...since I state them in the document before I define them.

Any ideas?

Twey
07-25-2006, 12:34 PM
Er... define $thetitle and $thetitle2 after $the_title and $the_title2. :) Only way.

If you want to take this to the next level, have a "template" page that deals with your site design, and then include it from the main page, which sets all the variables echoed into the template. The ideal site model is one that separates content, logic and design.

blm126
07-25-2006, 12:35 PM
Not sure what's with all the quotes.Try this.


if ($page == 'about') {
$the_title = 'us';
$the_title2 = 'me';
$mrtitle = 'About Us';
$mrtitle2 = 'About Me';

echo $thetitle.'

<p>We're a branch of Flame Html Studios, a web design firm based in Cleveland, Ohio. This blog exists to
inform the public of interesting, helpful, entertaining, and practical topics relating to such things
as art, web design, programming, Faith, etc.</p>

<p>We strongly believe in the web standards set out by the W3C, and we strive to create out sites more
simple in every new design, idea, and line code that we spit out.</p>

'.$titlebot.$thetitle2.'

<p>My name is Alex Jewell. I'm a web designer, photographer, writer, artist, musician, and strong
Christian. As the founder and only designer, at this point, of Flame Html Studios, I learn more in the
realm of technology and design everyday. This blog is you learning what I do as I do.</p>

<p>I'm 14. I'm rad. I'm a geek. I love music. I love life. I love writing. I love design. Enjoy this
little project.</p>

'.$titlebot;
}

alexjewell
07-26-2006, 12:43 AM
Hey, thanks. That's what I feared, Twey!
Haha

[and to blm126 - I like doing using double quotes instead of single quotes. but thanks, anyway.]

Anyway, the project is finally up and finished.

check it out:

http://www.flamehtmlstudios.com/longroad/

Heck, leave some comments if you want to? Thanks.

Twey
07-26-2006, 12:58 AM
alexjewell: He didn't use single quotes just for the fun of it :) Single quotes are significantly faster to parse than double (especially with long strings like that one), and should be used wherever possible. I know, I find it unnatural to put more than a single character in single quotes too. :p