Skip to main content
Topic: STFS: Smart Title For SEO (Read 2610 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

STFS: Smart Title For SEO

STFS: Smart Title For SEO

For Elk 1.0.x & 1.1 Beta x.
Hook. No File Modification.

1. Please do your own backup though every installation is backed up automatically.
2. On default the "- Index" can be seen on the browser as forum index page title and this mod when enabled will remove it.
3. This mod will now also change your forum title from "page title" to "forum name - page title".
4. Upon its successful installation, you will be directed to addons page where you can enable/disable this mod.
5. There is nothing fancy about this mod as it is just a simple trick to boost a bit of SEO (at least IMO).
6. You can test it in lower version too as IMO it should work just fine. ;)


Thank you for using/testing it.


Yours friendly,
Abu Fahim Ismail.

BSD License. Feel free to modify accordingly but keep author's link if it is in there somewhere. ;)

 





Re: STFS: Smart Title For SEO

Reply #1
#Change Logs

@Version 1.1.2
- Change version numbering to 1.0.x style.
- Fix settings to jquery to show other settings immeditely upon enable is checked.

Spoiler (click to show/hide)

Re: STFS: Smart Title For SEO

Reply #2
Will this display the topic title or just the number of the topic.  I have this installed and showing as /index.php/topic,2.0.html.

Re: STFS: Smart Title For SEO

Reply #3
2. On default the "- Index" can be seen on the browser as forum index page title and this mod when enabled will remove it.
3. This mod will now also change your forum title from "page title" to "forum name - page title".

Meaning if your forum normally found in searches and browser title as ElkArte - Index, it will now be only ElkArte. Some of the pages like this topic page will be found in searches and browser title as STFS: Smart Title For SEO, it will now be ElkArte - STFS: Smart Title For SEO. It is only doing something like that not more. Not even as per your understanding above. Sorry. :)

Re: STFS: Smart Title For SEO

Reply #4
Thank you for the reply, I just wanted to make it was working properly.

Re: STFS: Smart Title For SEO

Reply #5
On SMF I have the Optimus Brave mod and the titles generated with Optimus Brave are:
{board_name} - {forum_name}
and for topics:
{topic_name} - {board_name} - {forum_name}

Is there a way to tweak this mod to have the same results?

thank you
sorry for my bad english

Re: STFS: Smart Title For SEO

Reply #6
Something like these two is possible:
{topic_name} - {forum_name}
{board_name} - {forum_name}

Open STFS.subs.php and simply change this code:
Code: [Select]
		$title_new = '<title>' . (empty($context['page_title_html_safe']) ? $context['forum_name'] : $context['forum_name']. ' - ' . $context['page_title_html_safe']) . '</title>';

To:
Code: [Select]
		$title_new = '<title>' . (empty($context['page_title_html_safe']) ? $context['forum_name'] : $context['page_title_html_safe'] . ' - ' . $context['forum_name']) . '</title>';

Re: STFS: Smart Title For SEO

Reply #7
It works, but is there a simple way to include the board name of that topic? I'm asking this because I don't want to change all titles of my forum.

Thank you in advance
sorry for my bad english

Re: STFS: Smart Title For SEO

Reply #8
Possible but that have to defined inside the topic source file. I think it is in Display. Let me check first.

Re: STFS: Smart Title For SEO

Reply #9
Ok. I got it now. Simply change the whole buffer code to this one:

Code: [Select]
function STFS_Titles(&$buffer)
{
global $modSettings, $context, $topic, $board_info;

if (isset($_REQUEST['xml']) || $context['current_action'] == 'printpage') return $buffer;

$stfs = array();

// Define the old and the new title
if (!empty($modSettings['stfs_enable'])) {
$title_old = '<title>' . $context['page_title_html_safe'] . '</title>';
$title_new = '<title>' . (empty($context['page_title_html_safe']) ? $context['forum_name'] : $context['page_title_html_safe']) . ' - ' . $context['forum_name']. '</title>';
$stfs[$title_old] = $title_new;
}
if (!empty($modSettings['stfs_enable']) && !empty($topic)) {
// Define the old and the new title
$title_old2 = '<title>' . $context['page_title_html_safe'] . '</title>';
$title_new2 = '<title>' . (empty($context['page_title_html_safe']) ? $context['forum_name'] : $context['page_title_html_safe']) . ' - ' . $board_info['name'] . '  - ' . $context['forum_name']. '</title>';
$stfs[$title_old2] = $title_new2;
}
// Now let's change the title, if we're allowed to
return str_replace(array_keys($stfs), array_values($stfs), $buffer);
}

I will consider to add the following option later in the mod:
1. Board name in topic title as per what you wanted.
2. Option for left to right or right to left. e.g.
Default - Forum Name - Board Name - Topic Name
Other - Topic Name - Board Name - Forum Name

I prefer forum name first as default since I normally search by typing site name followed by the search key.

Re: STFS: Smart Title For SEO

Reply #10
Out of curiosity, did you already try using integrate_load_theme instead of a buffer replacement?
At that point you should be able to replace the content of $context['page_title_html_safe'] to whatever you want. ;)
Bugs creator.
Features destroyer.
Template killer.

Re: STFS: Smart Title For SEO

Reply #11
Actually, I haven't. I will surely try that soon. Thanks for the tips @emanuele.

Re: STFS: Smart Title For SEO

Reply #12
Thank you @ahrasis , it's working
sorry for my bad english

Re: [ADDON] STFS - Smart Title For SEO

Reply #13
Out of curiosity, did you already try using integrate_load_theme instead of a buffer replacement?
At that point you should be able to replace the content of $context['page_title_html_safe'] to whatever you want. ;)

I am testing this new approach with no success. Hook:
Code: [Select]
'integrate_load_theme' => 'STFS_Titles|SOURCEDIR/addons/STFS.subs.php',

Code:
Code: [Select]
function STFS_Titles()
{
global $modSettings, $context, $topic, $board_info;
// Load language(s)
loadLanguage('STFS');
// Redefine page title(s)
if (!empty($modSettings['stfs_enable'])) {
if (!empty($context['page_title_html_safe']) && !empty($topic))
$context['page_title_html_safe'] = $context['forum_name']. ' - ' . $board_info['name'] . '  - ' . $context['page_title_html_safe'];
if (!empty($context['page_title_html_safe']))
$context['page_title_html_safe'] = $context['forum_name']. ' - ' . $context['page_title_html_safe'];
else
$context['page_title_html_safe'] = $context['forum_name'];
}
}

Any ideas how to make this integrate_load_theme works?

The trial package attached.

Re: [ADDON] STFS - Smart Title For SEO

Reply #14
Weeeeell... it's not that it *has* to work, it may have been a broken suggestion to begin with.
That one was really a suggestion in the sense "it may work or not, I'm not sure", sorry for not making it more clear... :-[

And reading better the code, it cannot work... I gave you a bad advise, I'm sorry. :(

But, that is something we should consider, the hooking is not really symmetric: there are lots of ways to hook the "starting" of ElkArte, but not a single one that allows to change stuff just before the template is sent out. <= improvements needed.
Bugs creator.
Features destroyer.
Template killer.