ElkArte Community

Extending Elk => Addons => Topic started by: ahrasis on August 07, 2014, 11:59:27 am

Title: STFS: Smart Title For SEO
Post by: ahrasis on August 07, 2014, 11:59:27 am
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. ;)

(http://validator.w3.org/images/valid_icons/valid-xhtml10)  (http://jigsaw.w3.org/css-validator/images/vcss)


(http://www.elkarte.net/community/index.php?action=dlattach;attach=1241;image)

(http://www.elkarte.net/community/index.php?action=dlattach;attach=4381;image)
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on October 08, 2014, 01:37:23 pm
#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)
Title: Re: STFS: Smart Title For SEO
Post by: Allan on December 13, 2014, 08:14:44 am
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.
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 13, 2014, 11:15:08 am
Quote from: ahrasis – 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. :)
Title: Re: STFS: Smart Title For SEO
Post by: Allan on December 13, 2014, 11:19:59 am
Thank you for the reply, I just wanted to make it was working properly.
Title: Re: STFS: Smart Title For SEO
Post by: radu81 on December 18, 2014, 03:17:11 am
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
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 18, 2014, 01:26:26 pm
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>';
Title: Re: STFS: Smart Title For SEO
Post by: radu81 on December 20, 2014, 04:49:18 pm
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
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 21, 2014, 01:33:19 am
Possible but that have to defined inside the topic source file. I think it is in Display. Let me check first.
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 21, 2014, 02:15:45 am
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.
Title: Re: STFS: Smart Title For SEO
Post by: emanuele on December 21, 2014, 04:28:38 am
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. ;)
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 21, 2014, 05:09:47 am
Actually, I haven't. I will surely try that soon. Thanks for the tips @emanuele.
Title: Re: STFS: Smart Title For SEO
Post by: radu81 on December 21, 2014, 06:49:36 am
Thank you @ahrasis , it's working
Title: Re: [ADDON] STFS - Smart Title For SEO
Post by: ahrasis on December 21, 2014, 08:21:49 am
Quote from: emanuele – 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.
Title: Re: [ADDON] STFS - Smart Title For SEO
Post by: emanuele on December 21, 2014, 09:36:10 am
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.
Title: Re: [ADDON] STFS - Smart Title For SEO
Post by: ahrasis on December 21, 2014, 10:15:10 am
Hey! No worries. I like to try and test all the given codes though it may be broken or not working at all. That's how I learn most of the time - via errors. Keep tipping me. I like to have plenty of ideas in doing certain things rather than no or limited ideas in doing them. I have more fun learning that way.
Title: Re: [ADDON] STFS - Smart Title For SEO
Post by: ahrasis on July 26, 2016, 01:06:38 am
Updated...

#Change Logs

@Version 1.3.1
- Removing unnecessary code.
- Restructuring addons directory and location.
Title: Re: [ADDON] STFS - Smart Title For SEO
Post by: Jorin on July 26, 2016, 01:10:34 am
Quote from: ahrasis – Hey! No worries. I like to try and test all the given codes though it may be broken or not working at all. That's how I learn most of the time - via errors. Keep tipping me. I like to have plenty of ideas in doing certain things rather than no or limited ideas in doing them. I have more fun learning that way.

Great attitude! thumbsupsmileymissing
Title: Re: [ADDON] STFS - Smart Title For SEO
Post by: ahrasis on August 11, 2016, 04:40:39 am
#Change Logs

@Version 1.3.2
- Standardizing files' location.
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on November 01, 2016, 10:50:11 am
#Change Logs

@Version 1.3.3
- Make it work for 1.1 Beta 3.
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on November 11, 2016, 07:26:18 pm
#Change Logs

@Version 1.3.4
- Restored location back to /sources/addons.
- Fixed intgerate buffer error in PHP 7.
Title: Re: STFS: Smart Title For SEO
Post by: Burke Knight on December 15, 2016, 08:33:55 am
If using SimplePortal, the site title gets duplicated on main portal.
I can't link the site, as it's not accessible to others yet.
But, forum tab shows the title one time, just the portal page has it duplicated.

Also, suggestions for future updates:
1. Ability to have site title positioned by switch, to left or right of page title.
2. Ability to enter title want, into a field.
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 15, 2016, 11:42:42 pm
I am not so sure whether this addon can affect SimplePortal as it is only aimed to change the title in the browser for Elk. Normally, you will need to find the code that generates that title and change it OR maybe, just a maybe, you can add the code while creating the page i.e. inside that page code itself?

As per your first suggestion, the current one is already on the right, so this addon only change it to the left. I am not so sure about the second one though. Do you mean the ability to change the title of your forum? That should be done inside the forum ACP, don't you think? But, please, do clarify more if you mean other things per your suggestion.
Title: Re: STFS: Smart Title For SEO
Post by: Burke Knight on December 16, 2016, 08:12:27 am
1. Could add a selector, for those that have SimplePortal, that when checked, does not display the title on the main forum page. Normally, this would be the forum board listing, but with SP, it often is the main portal page. This is not a custom page you can edit through the SP pages function.

2. This addon adds the site title to page title, not just move from right to left. Without this addon, when I look at any page on the forum, it just tells the page title, and not the site title. So, a selector, would be nice to let the admin decide if they want site title to left or right of page title. (Yes, explained more in depth, for people not so familiar with the addon.)

Examples:
Unchecked: ElkArte Community - STFS: Smart Title For SEO
Checked: STFS: Smart Title For SEO - ElkArte Community

3. Sometimes, a site has a short name, which gets used for title, and a longer name that the logo would show. Like a couple of my sites, for example. The reason it's so, is that sometimes, where the forum shows the forum name, if it is long, it can look not so well. Luckily, some of that was fixed, by using the Home icon in linktree, instead of the whole forum name. However, there's still some other places.

My idea on the field, is for admins to maybe use a different name than the site's name is in settings. More a way to add to it, without adding to the official site name in settings.

Example: In settings: All Points Web Hosting
In custom field: All Points Web Hosting - Community Forum

Both, with page title before/after, depending on above switch.
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 16, 2016, 09:04:49 am
1. I am not sure about SP as I am not using it.

2. Check and uncheck is there in the addon settings. If unchecked, the forum name will be at the end i.e default. If checked, the forum name will be at the first i.e. in contrast to default.

3. I will consider it. A field for it can be added in its settings.
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on December 16, 2016, 01:39:56 pm
#Change Logs

@Version 1.3.5
- Added board option e.g. ElkArte - Board - Page Title.
- Added reverse option e.g. Page Title - Board - Elkarte.

@Burke Knight, though not all, the addon has been updated to accommodate some of the ideas. I hope you like it.

(http://www.elkarte.net/community/index.php?action=dlattach;attach=4381;image)
Title: Re: STFS: Smart Title For SEO
Post by: ahrasis on September 02, 2017, 07:16:51 am
#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.