Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
placing category name in title of html page

 

 


pchell
User

Oct 19, 2009, 12:46 PM

Post #1 of 5 (1908 views)
Shortcut
placing category name in title of html page Can't Post

I have an articles section editor in CMS Builder. One of the fields in the data is category, so I can categorize the different articles and show those articles in a articlelist.php file for each category. Every works except one thing, I want to take the category name and place it in the title of the html page as well as on the articlelist.php page. Right now I just have the title and heading as "article" on the page, I want it to say "Category 1 articles", "Category 2 articles", etc. for each article list.

I've tried adding $record['title'] to the page but it does not work. I'm using the following codes in the header and body

---- header ----
<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */
require_once "/usr/home/sbsheep/public_html/cms/lib/viewer_functions.php";

list($articlesRecords, $articlesMetaData) = getRecords(array(
'tableName' => 'articles',
'perPage' => '10',
));

?>
--------------------

-----Body----------

<h2 class="art-PostHeaderIcon-wrapper">
<span class="art-PostHeader"><center>Articles</center></span>
</h2>
<div class="art-PostContent">
<?php foreach ($articlesRecords as $record): ?>

<a href="<?php echo $record['_link'] ?>"><?php echo $record['pagetitle'] ?></a><br/>

Thanks!


Chris
Staff


Oct 20, 2009, 9:49 AM

Post #2 of 5 (1897 views)
Shortcut
Re: [pchell] placing category name in title of html page [In reply to] Can't Post

Hi pchell,

I have a couple of questions for you:

How does your articlelist.php page know which category to display? Are you linking to "articlelist.php?category=2"?

Also, how is your Articles' "category" field configured? Do you have a hard-coded list of options or are you using "Get options from database (advanced)"?
Chris


pchell
User

Oct 20, 2009, 3:47 PM

Post #3 of 5 (1890 views)
Shortcut
Re: [chris] placing category name in title of html page [In reply to] Can't Post

Chris,

I am linking to the articles with this code ""articlelist.php?category=2"

As far as the categories are concerned, its a static hard coded dropdown list that I created to choose from. Currently it has 3 categories in it.

Thanks!




Chris
Staff


Oct 20, 2009, 5:08 PM

Post #4 of 5 (1888 views)
Shortcut
Re: [pchell] placing category name in title of html page [In reply to] Can't Post

Hi pchell,

How about this?


Code
<title>Category <?php echo htmlspecialchars($_REQUEST['category']) ?> articles</title>


I hope that helps. Please let me know if you have any more questions.
Chris


pchell
User

Oct 20, 2009, 5:26 PM

Post #5 of 5 (1883 views)
Shortcut
Re: [chris] placing category name in title of html page [In reply to] Can't Post

Thanks again Chris,

That worked great!