PDA

View Full Version : Extra Category title


Mark Brookes
12-05-2006, 04:47 PM
Hi,

At the moment for each category the administrator can specify

* a path, for the browser address bar & url
* A title to describe the category.

This title is used on the Category index / Directory Home page and on the individual category pages.

I would like a different title on the individual category pages.

Specifically I would like the individual category pages to have titles such as:
Wedding caked
Wedding Dresses
Wedding Transport
Wedding Planning
etc etc

But If I keep repeating the word "wedding" in the directory home page, then
* the category titles tend to overlap
* it swamps the page with the word "Wedding"
*** making it harder for visitors to understand the page
*** possible making SEs Judge it as Keyword spamming.

I think this issue is valid for more than just my site - consider a books directory with a sub category like:

* Science fiction
*** Science fiction - SF Classics
*** Science fiction - Hi Tech
*** Science fiction - hard science
*** Science fiction - Post Appocalypse
*** Science Fanstsy
***** Science Fanstsy - Alternate History
***** Science Fanstsy - Space Opera
etc etc

In this example it would be good for the <h1> on each category page to have the full title as above.

But it would be better for the index page to have different titles such as:

* Science fiction
*** SF Classics
*** Hi Tech
*** hard science
*** Post Appocalypse
*** Science Fanstsy
***** Alternate History
***** Space Opera


Convinced?

Can we have the extra title field for categories in the next version?
You could call them:
* Category title - index page
* Category title - Category pages




Is it possible to easily modify the current code?


Regards
Mark

John Turner
12-06-2006, 05:45 AM
Hi Mark,

Open your '../templates/{YOUR TEMPLATE}/header.tpl'

*** find following code

<title>{$title}&nbsp;{$config.suffix}</title>

*** find following code

<title>{if $category.id eq 0}{$title}{else}{$category.title}{/if}&nbsp;{$config.suffix}</title>


It might helps.

Mark Brookes
12-06-2006, 09:18 AM
Hello John,

Thank you for your reply ...
The change does not appear to have made any difference.
Would you tell me what values the parameters refer to:-
*{$title}
*{$category.title}

I assumed they related to
Admin-panel > browse > edit-category - path
Admin-panel > browse > edit-category - title

but that does not seem to be the case. Any extra advice?




Perhaps a bit more explanation of what I desire:
Admin-panel > browse > edit-category

Path - e.g wedding-accessories [address url optimised for SEs, with "-" between words]

Index Title - e.g Accessories [Title for Directory Home Page, optimised for visitor display convenience & to avoid keyword spamming]

Category Title - e.g Wedding Accessories [title for individual category pages, optimised <h1> including target keyword]

In most of my particular categories the only difference between path & Category title is the hyphen.

Regards
Mark

John Turner
12-06-2006, 09:36 AM
Probably I miss understand.

{$title}- this value, one can to change via AdminPanel > General Configuration-> "Site title"

{$category.title} - this is Category title

Hope it helps.

Mark Brookes
12-06-2006, 09:50 AM
Hi John,

OK, I see.
SO what I want is for {$category.title} to be used in the Directory Index page

and a new variable - value say {$category-h1.title} or {$category-page.title}

Hopefully, this would be "easy" to add in a new version (2.2?)

but for the existing version I see several issues.
* need an extra field in _categories table ( I think?)
* need to add the new field to the admin-panel>browse>edit-category page
* need to change php file(s) [header.tpl ?) to use the new field.


Is this practical for a mod?
regards
Mark

Mark Brookes
12-07-2006, 10:01 AM
Hello John,

Thank you for working on this idea.

* I can see the new field page_title in the phpMyAdmin _categories table

* I have added some page-Title values in the new fields at admin-panel > browse > edit categories in the 'Attire' branch of categories. And I have saved the new values. I confirm that the new values are stored in _categories table &page_title field

* I can see the new code added at line 5 of header.tpl

However if you visit http://www.finespeeches.com/wedding-resources/ you will see that (in the 'attire' categories) it is still $title not $page_title which is being displayed.

Is there something else which I should do to make the $page_title values disdplay on the directory pages?

regards
Mark

John Turner
12-07-2006, 10:56 AM
There is Site Title for ROOT category

Please check this
http://www.finespeeches.com/wedding-resources/Wedding-Attire/
http://www.finespeeches.com/wedding-resources/Wedding-Attire/Wedding-Jewellery/

So, if page_title field is not empty for selected category {page_title} is displayed, else {title} is displayed

Mark Brookes
12-07-2006, 12:05 PM
Hi John

So, if page_title field is not empty for selected category {page_title} is displayed, else {title} is displayed

That is what I was expecting, but ....

* although I have saved a page_title for category = Attire (see attachment ...Edit)( & attachment _categories)

* the Directory does not display the value in page_title (see attachment ...Displayed)

Sergey Ten
12-08-2006, 08:53 PM
Hi, Mark!

I have changed your directory, please check it. And please post the result.

Mark Brookes
12-09-2006, 08:37 AM
Hello Sergey

Thank you for yuor help.

We are making progress ....

When I have entered a value for category > page-title that title now displays in the Directory -- Good :) attachment 101

however, when I have not entered a value for category > page-title No title appears now displays in the Directory --- not-ok attachment 102


So the bit of code which saya ... if page-title is empty then display 'title' seems to be not working.

Mark Brookes
12-17-2006, 02:18 PM
Hello Sergey, John,

Since the last post I have had problems with my live directory, and I appear to have lost the adjustments for the Extra category title.

Please could you provide me with the code changes needed to implement the modification myself.

Please can we limit any experimental work to http://www.finespeeches.com/wedding-resources-TEST/

THnaks
Mark

John Turner
12-18-2006, 11:06 AM
Hi there,

This mod would be suitible for all

0. Add new field to your {prefix}categegories table

ALTER TABLE `{prefix}categories` ADD `page_title` VARCHAR( 250 ) NULL AFTER `title` ;


1. Open your '../admin/edit-category.php'
**find following code

if ($_POST['edit_category'])
{
$temp['id'] = $_GET['id'];
$temp['title'] = sql($_POST['title']);

*** add following code after it

$temp['page_title'] = sql($_POST['page_title']);


**find following code

<tr>
<td><strong><?php echo $gDirLang['title']; ?>:</strong></td>
<td><input type="text" name="title" size="30" maxlength="150" value="<?php echo $category['title']; ?>" <?php echo ($_GET['id'] == 0) ? 'readonly ' : ''; ?>/></td>
</tr>

*** add following code after it

<tr>
<td><strong>Page title:</strong></td>
<td><input type="text" name="page_title" size="30" maxlength="150" value='<?php echo $category['page_title']; ?>' <?php echo ($_GET['id'] == 0) ? 'readonly ' : ''; ?>/></td>
</tr>

*** save and close it

2. Open your '../admin/suggest-category.php'
**find following code

if ($_POST['add_category'])
{
$temp['id_parent'] = $id_parent;
$temp['id_editor'] = 0;
$temp['title'] = sql($_POST['title']);

*** add following code after it

$temp['page_title'] = sql($_POST['page_title']);


***find following code

<tr>
<td><strong><?php echo $gDirLang['title']; ?>:</strong></td>
<td><input type="text" name="title" size="30" maxlength="150" value="<?php echo $_POST['title']; ?>" /></td>
</tr>

*** add following code after it

<tr>
<td><strong>Page title:</strong></td>
<td><input type="text" name="title" size="30" maxlength="150" value='<?php echo $_POST['page_title']; ?>' /></td>
</tr>

*** save and close it.

3. Open your '../templates/{YOUR TEMPLATE}/header.tpl'
***find following code

<title>{$title}&nbsp;{$config.suffix}</title>


***replace it with following code

<title>{if $category.page_title && $category.id neq 0}{$category.page_title}{else}{$title}{/if}&nbsp;{$config.suffix}</title>

*** save and close it.

It might helps.

Mark Brookes
12-18-2006, 07:16 PM
Hello John

Thanks for this update.


What a brilliant idea to modify the <title> tag; I had not even thought of that - good for SE optimisation though :)


However when I spoke about category titles I had thought the page_title field would be used for the <h1> tag. On the same basis - i.e If there is a page_title then use it else use category title. Could you please tell me the code to get the <h1> tag to display the new page_title (if there is one)


Thanks
Mark

John Turner
12-19-2006, 04:52 AM
Hi Mark,

Here the code:

open your '../templates/{YOUR TEMPLATE}/index.tpl'

***find following code

<h1>{$header}</h1>


***replace it with following code

<h1>{if $category.page_title && $category.id neq 0}{$category.page_title}{else}{$header}{/if}</h1>


Hope it helps.

Mark Brookes
12-19-2006, 09:32 AM
THANK YOU John!

A superb Mod.
For anyone who wants a brief title on the Directory home page and a keyword focused title on the category pages (<title> & <h1>)

What do you think about building this into a future version ? ;)


For anyone who wants to avoid all the searching & cutting & pasting I attach the 4 changed files. - You will still need to run the SQL (above) to add the database field

Mark Brookes
12-19-2006, 09:33 AM
... and the missing attachment ...

John Turner
12-19-2006, 09:58 AM
You are welcome Mark.
Always at your services.

juliusbarra
03-15-2007, 10:21 AM
Excellent, but when I go to "Add Your Site" clicking from inside the category, and when I go to "Link Detail" it still maintains the category page title.

juliusbarra
03-16-2007, 10:46 AM
Maybie I didn't explain well.
Before the mod, the Link Detail Paige had as title the name of the Link, now it has the same title of the category.

The same issue is for the Add Link page (only if click from inside the category), now it has the same title of the category.

Mark Brookes
07-24-2007, 01:27 PM
Hello John (?)

Back for Version 2.1.03 :)

I have worked through my ver 2.0.01 MOD and mostly applied it to Ver 2.1.03 but I have become stuck at the edit-category.php changes because the php code is so very different in this file.

I think I just need help with how to make edit-category.php save the changes when administrator edits category details. In ver 2.0.01 I needed to add $temp['page_title'] = sql($_POST['page_title']);
at line 33. But the equivalent in the new edit-category does not work at all.



Just to explain, this is what I've done so far:

[1] index.tpl
Line 4:
was <h1>{$header}</h1>is now <h1>{if $category.category_page_title && $category.id neq 0}{$category.category_page_title}{else}{$header}{/if}</h1>where category_page_title is the new field name in the categories table.


[2] header.tpl
Line 6:
was <title>{$title}&nbsp;{$config.suffix}</title>is now: <title>{if $category.category_page_title && $category.id neq 0}{$category.category_page_title}{else}{$title}{/if}&nbsp;{$config.suffix}</title>


[3] edit-category.php


[3A] Add new field to Admin-Panel >> Edit Category
At line 418 insert new lines

<tr>
<td><strong>Title ..... (CategoryLinks-ListingPage):</strong></td>
<td><input type="text" name="categoty_page_title" size="50" maxlength="250" value='<?php echo $category['category_page_title']; ?>' <?php echo ($_GET['id'] == 0) ? 'readonly ' : ''; ?>/></td>
</tr>
** In Admin-panel >> Manage Language
Change value of key "title" to "Title ..... (Category Name for categoryIndexPage)"
Change value of key "path" to "Path ..... (Browser URL)"






[3B]?? save edits ??

here is where my problem starts. in ver 2.0.01 there was some code
if ($_POST['edit_category'])
{
$temp['id'] = $_GET['id'];
$temp['title'] = sql($_POST['title']);

$temp['description'] = sql($_POST['description']);
$temp['meta_description'] = sql($_POST['meta_description']);
$temp['meta_keywords'] = sql($_POST['meta_keywords']);
$temp['status'] = $_POST['status'];
$temp['num_cols'] = $_POST['num_cols'];
$temp['neighbour'] = $_POST['num_neighbours'];
$temp['locked'] = $_POST['locked'];
and I had to add
$temp['page_title'] = sql($_POST['page_title']); However the ver 2.1.03 code is different ...

if (isset($_POST['edit_category']))
{
$newPathSpecified = false;

loadUTF8Core();
loadUTF8Util('validation');
loadUTF8Util('bad');
loadUTF8Util('ascii');

$temp['category_page_title'] = sql($_POST['category_page_title']);
$temp['id'] = $_GET['id'];
$temp['status'] = valid_status($_POST['status']) ? $_POST['status'] : '';
$temp['num_cols'] = (int)$_POST['num_cols'];
$temp['neighbour'] = (int)$_POST['num_neighbours'];
and although I have added the equivalent code $temp['category_page_title'] = sql($_POST['category_page_title']); in various places :) I can't get it to work properly ... I can't save edited category data in admin-panel.






[4] admin/suggest-category.php

I have a similar problem with the new style code in suggest-category.php,

if ($_POST['add_category'])
{
$temp['id_parent'] = $id_parent;
$temp['id_editor'] = 0;
$temp['title'] = sql($_POST['title']);
>>>>>> $temp['page_title'] = sql($_POST['page_title']); <<<<<<
$temp['description'] = sql($_POST['description']);
I would really appreciate help with this modification.

Thanks
mark

Mark Brookes
08-04-2007, 11:47 AM
ho humm,
gentle BUMP

Mark Brookes
08-16-2007, 05:13 PM
whimper ....:)
whimper....:)
............... Bump

Mark Brookes
09-10-2007, 10:26 AM
Gentle bump.