Title Tag

10 posts by 3 authors in: Forums > CMS Builder
Last Post: March 16, 2010   (RSS)

By dustindd - March 12, 2010

Is there a way to generate the title of a page (for example an article title) as the title tag using CMS Builder? Example: http://www.dustindrorbaugh.com/html/news.php?Sears-Scrambles-Online-for-a-Lifeline-2 would have the title tag of Sears Scrambles Online for a Lifeline.

Dustin
Dustin Drorbaugh
http://www.DustinDrorbaugh.com

Follow Me On Twitter: http://www.twitter.com/dustindd

Re: [dustindd] Title Tag

By Donna - March 12, 2010 - edited: March 12, 2010

Hi Dustin!

You bet. Just put your title code into the <title> tag. So, you'd have something like this:

<title><?php echo htmlspecialchars($mainRecord['title']) ?></title>

Let me know if that works for you. :)
Donna

--
support@interactivetools.com

Re: [Donna] Title Tag

By dustindd - March 15, 2010

Hi Donna,

That did not work. Instead of the article title being displayed the entire URL of the file is displayed. I attached my php file if you want to take a quick look.
Dustin Drorbaugh
http://www.DustinDrorbaugh.com

Follow Me On Twitter: http://www.twitter.com/dustindd

Re: [dustindd] Title Tag

By Donna - March 15, 2010

Hi Dustin,

It doesn't look like the file got attached, can you try that again?
Donna

--
support@interactivetools.com

Re: [Donna] Title Tag

By dustindd - March 15, 2010

www.dustindrorbaugh.com/news.zip
Dustin Drorbaugh
http://www.DustinDrorbaugh.com

Follow Me On Twitter: http://www.twitter.com/dustindd
Attachments:

news.php 18K

Re: [dustindd] Title Tag

By Donna - March 15, 2010

Hi Dustin!

Make sure the code from CMS Builder is right at the top of the page. Where it says "Step 1" that should be at the VERY top, before anything else (even before your doctype declaration.)

The title isn't showing because it doesn't know where to grab it from -- the PHP works "in order" from top to bottom of the page, so anything above that code block won't show.

I hope this helps. :)
Donna

--
support@interactivetools.com

Re: [dustindd] Title Tag

By aev - March 16, 2010


Try this..

Change:
<title><?php echo htmlspecialchars($mainRecord['title']) ?></title>

To:
<title><?php echo htmlspecialchars($newsRecord['title']) ?></title>

-aev-

Re: [dustindd] Title Tag

By Donna - March 16, 2010

Hi Dustin,

Yup, what aev said -- with any examples we give, make sure you change any variables (like the section names) to match your own. You can compare against the code from your code generator -- all this is is the bit of echo code for the "title" field. :)
Donna

--
support@interactivetools.com

Re: [Donna] Title Tag

By dustindd - March 16, 2010

Yes aev's solution worked. Thank you for your help!
Dustin Drorbaugh
http://www.DustinDrorbaugh.com

Follow Me On Twitter: http://www.twitter.com/dustindd