jrharper commented on a Page, Dynamic Title and Meta Tags  -  Jan 07, 2013

hawkee,

I have the title part working on my site,I used [if($category) print $category; if($subcategory) print $subcategory; print $title;] so that it would diplay $title before anyone clicked on $category or $subcategory. The value of $title is Products, so it just prints after $category or $subcategory is clicked, so my title becomes Art($category)Products($title).

My problem is that each page is loaded inside of my header as page1.html. All listings on the page are from $category or $subcategory. I'm not sure how to go about getting the keywords part to work. I don't need keywords for every page, just $category or $subcategory.

Your welcome to look at my site to see what I'm talking about.

Thank You

Hawkee  -  Jan 07, 2013

I'm not too clear what you mean. Can you illustrate your point with some example URLs and the code changes you made?

jrharper  -  Jan 07, 2013

My variables:

$page = $_GET['page'];
$search = $_GET['search'];
$search = str_replace("-", " ", $search);
$search = stripslashes($search);
$category = $_GET['category'];
$subcategory = $_GET['subcategory'];

variable I added:

$title = ' Products';

The change I made:

<?php if($category) print $category; if($subcategory) print $subcategory; print $title; ?>

this is the area I want to change because they stay the same:

jrharper  -  Jan 07, 2013

example url: www.jrharper.com/products/index.php

jrharper  -  Jan 07, 2013

The menu system on the left side is a list of the values in $category and $subcategory. what I want to do is link seperate description and keyword to each value in $category and $subcategory.

jrharper  -  Jan 07, 2013

What I am wondering is if I can create a php page structured like this

if($category='Arts_and_Entertainment') then ($meta_keywords='') and ($meta_description='');
if($category='Betting_Systems') then ($meta_keywords='') and ($meta_description='');
if($category='Business/Investing') then ($meta_keywords='') and ($meta_description='');

with all of my $categories and $subcategories keywords and descriptions and then call this page from my header?

Hawkee  -  Jan 07, 2013

Sure, you can do that, but the format would be more along these lines:

if($category == 'Arts_and_Entertainment') { 
    $meta_keywords = 'some keywords'; 
    $meta_description = 'a description'; 
}
jrharper  -  Jan 07, 2013

I tried both ways and neither one works. I can change the title, but not the meta tags. It leaves the meta tag blank even if I do just $meta_description alone.

jrharper  -  Jan 08, 2013

My title works using this:

<?php if($category) print $category; if($subcategory) print $subcategory; print $title; ?>

$title = ' Products';

onload title = Products, if any catagory (say Art) is clicked title = Art Products, and the same with the subcatagories

Is there a way that I could use the out-put from that to load keywords and descriptions for each category/subcategory?

Hawkee  -  Jan 09, 2013

@jrharper I'm sorry, but I'm just not very clear about what you are doing. Are you using the code provided on this page or are you building something entirely different? If you need some general programming questions answered you might want to try searching StackOverflow. It's a very good Q&A development resources.

jrharper  -  Jan 11, 2013

Problem Solved !!!
First I want to thank you for the code and letting me use this place as a backboard for my thoughts.

I wanted to use your code, but I only have page1.html that is displayed inside a header. What is displayed on page1.html is controlled by 2 variables that make up the menu, $category and $subcategory. To solve my problem I created a title.php file that is an if/elseif statement.

if($category == '' && $subcategory == '') {
print('Products');
}
elseif ($category == 'Arts-and-Entertainment') {
print('Arts and Entertainment');
}
elseif($category == 'Betting-Systems') {
print('Betting Systems');
}
elseif($category == 'Business-/-Investing') {
print('Business / Investing');

It has $subcategory in the same file lower down.(it's 746 lines long) I did this to format the output. then I put include('title.php') between the title tags.

Now I can copy the file twice and save them as description.php and keyword.php and all I have to do is change the print('') statements and then include them between the tags.

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.