FreeWebshop.org
June 20, 2013, 10:43:23 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Support the project. Please consider to donate a small amount
 
   Home   Help Search Login Register  
Pages: [1] 2 3   Go Down
  Print  
Author Topic: Mod to get a meaningful title on each page  (Read 12044 times)
sermoa
chaozz.nl Starter
*
Posts: 32



« on: June 28, 2008, 11:47:10 AM »

You know how every page in the shop has the same title (the name of your shop)? It's not so good when browsing history, because you can't know which page was which. Also, for SEO (search engine optimisation) it is good to have the product name in the page title.

I have found a way to accomplish this. It's a bit hacky, but it works thanks to the order in which the include files are read. It involves an extra database query for the product pages.

Code:
[readsettings.inc.php]

[find]
  // some strings you might want to change
  $slogan = $row[35];
  $page_title = $row[36];
[/find]

[modify]
  // some strings you might want to change
  $slogan = $row[35];
  $page_title = $row[36];
 
  // Something extra to append to the title
  if ($page != "") {
    $page_title_extra = ucfirst(preg_replace('/[^a-zA-Z0-9- ]/', '', $page));
  }
  if ($page == "info" && $action != "") {
    $page_title_extra .= " - " . ucfirst(preg_replace('/[^a-zA-Z0-9- ]/', '', $action));
  }
  if ($page == "details" && $prod != "") {
    // Look up the product name in the database
    $product_query = sprintf("SELECT `PRODUCTID` FROM `".$dbtablesprefix."product` where `ID`=%s", quote_smart($prod));
    $product_sql = mysql_query($product_query) or die(mysql_error());
    if (mysql_num_rows($product_sql) == 1) {
      $product_row = mysql_fetch_row($product_sql);
      $page_title_extra .= " - " . $product_row[0];
    }
  }
[/modify]

[/readsettings.inc.php]

The preg_replace strips out any nasty characters (like the ~ in the hidden 'extra' pages) and the ucfirst just ensures the first character is a capital letter.

Having done that, you can refer to $page_title_extra in your template:

Code:
<title><?php echo $page_title " - " $page_title_extra ?></title>

I'm attaching a screenshot as an example. It doesn't quite work because my computer doesn't seem to like taking screenshots of menus! But you can probably still see what the mod is doing.

Alternatively have a look at www.sheabliss.co.uk to see it.

[attachment deleted by admin]
Logged

black5
chaozz.nl Regular
**
Posts: 312



« Reply #1 on: June 29, 2008, 08:50:48 AM »

Hi, the title-mod looks good, but more impressing is the selection of the different tabs in the product page (see pic).

Is this a mod or a feature I have missed so far? And if it is a mod - how about telling us how it is done....

black5


[attachment deleted by admin]
Logged

------------------------------------------------------
http://stolpersteine.yourweb.de
sermoa
chaozz.nl Starter
*
Posts: 32



« Reply #2 on: June 29, 2008, 10:12:04 AM »

Ah yes, that is my 'info tabs' mod.

http://www.freewebshop.org/forum/index.php?topic=1313.0

That one, unlike the descriptive title, is safe to add without any risk of losing anything on a future upgrade.

Thanks for your compliment! Smiley
Logged

merchant
chaozz.nl Regular
**
Posts: 69


« Reply #3 on: June 29, 2008, 11:07:02 AM »

Hi, i have a little problem with this mod:
it displays only the page names witch you are on that moment on, like main and browse, but no product names. In witch version of freewebshop you've changed readsettings.inc?
I agree with black, the tab mod is great.
Logged
sermoa
chaozz.nl Starter
*
Posts: 32



« Reply #4 on: June 29, 2008, 11:10:21 AM »

Oh really? I am on 2.2.8. Which version are you on?
Logged

merchant
chaozz.nl Regular
**
Posts: 69


« Reply #5 on: June 29, 2008, 11:24:55 AM »

I am on version 2.2.9
Logged
sermoa
chaozz.nl Starter
*
Posts: 32



« Reply #6 on: June 29, 2008, 11:30:21 AM »

I will have a look ... see if i can figure out what the difference is.

I am looking at your shop right now - it makes me delighted to see my info tabs mod being put to good use! Smiley
Logged

merchant
chaozz.nl Regular
**
Posts: 69


« Reply #7 on: June 29, 2008, 11:34:53 AM »

You've done a good job on the tabs, it is a waste not to use this mod.
Logged
sermoa
chaozz.nl Starter
*
Posts: 32



« Reply #8 on: June 29, 2008, 11:52:01 AM »

Hey there, i have just tried the title mod on version 2.2.9 and it seems to work for me.

I think it is passing the conditions
if ($page == "details" && $prod != "")
because i can see them in the URL when i look at a product in your shop. So it must be failing at the condition
if (mysql_num_rows($product_sql) == 1)


There are two possibilities that you could try for the select statement: DISTINCT or LIMIT 1:

Code:
$product_query = sprintf("SELECT DISTINCT(`PRODUCTID`) FROM `".$dbtablesprefix."product` where `ID`=%s", quote_smart($prod));

or

Code:
$product_query = sprintf("SELECT `PRODUCTID` FROM `".$dbtablesprefix."product` where `ID`=%s LIMIT 1", quote_smart($prod));

If neither of those work, i'm afraid i don't know what the problem is. Perhaps chaozz will have a better idea.
Logged

merchant
chaozz.nl Regular
**
Posts: 69


« Reply #9 on: June 29, 2008, 12:30:39 PM »

The last option works fine for me, thanks.
I was puzzling too, because i have made some modifications in details en browse.php regarding the layout.
Logged
sermoa
chaozz.nl Starter
*
Posts: 32



« Reply #10 on: June 29, 2008, 12:35:30 PM »

Oh awesome, well done! Smiley Yeah i just saw it was working. It makes a real difference for browsing the history, doesn't it?.
Logged

merchant
chaozz.nl Regular
**
Posts: 69


« Reply #11 on: June 29, 2008, 12:48:36 PM »

Yes, it does make a lot of difference and that is very important for large shops.
Logged
sermoa
chaozz.nl Starter
*
Posts: 32



« Reply #12 on: June 29, 2008, 01:07:21 PM »

You could probably do a similar thing to output the name of the category/group on the browse pages.

My client's webshop is not big enough to be worth using categories and groups, and i find them quite confusing. But i'm sure it would not be difficult. It's probably something like
if ($page == "browse" && $cat != "")
and then do a very similar kind of query from the fws_category table.
Logged

merchant
chaozz.nl Regular
**
Posts: 69


« Reply #13 on: June 29, 2008, 05:43:38 PM »

I wil try this later in my demoshop
Logged
joepmeloen
chaozz.nl Starter
*
Posts: 2


« Reply #14 on: September 24, 2008, 09:23:57 AM »

This mod is definitely a very good step, thank you for it!

These days seo is a very important part of web development. With a few simple changes this webshop could do so much better in the seo field then it does right now.

I've been advising a client of ours who uses freewebshop, I've been telling him what he should change in order to rank higher on product names and important meaningfull keywords.

I'm going to write my advise down in this topic so maybe the developer of this mod could add them to this mod, or -even better- the developer of fws could implement them in the core and make fws a more seo friendly shop. The following comments are merely meant as feedback, don't be angry with me :-). I could not find another place to put this..

Ranking for Product names :

When a customer is looking for a certain product.. what is he/she most likely to search for..? Yes, the product name that's right! Wouldn't it be great to rank higher for product names?

Things to change :

1. Make sure your product names show's up in the <title> element, like the above mod will accomplish.

2. Make sure your product name shows up in article details title and make this title a <h2> element (FWS : Why did you make this a <h5> element if I may ask?).
A <h2> title is considered as 'very important' by Google and using it here seems appropriate.


Ranking for important meaningfull keywords :

There maybe some basic important keywords that you want to use on every page. You could use these words in your description. this description will show up on the SERP (Search engine results page) so why not make it a great piece of text while you are at it! :-)

Things to change

1. Remove the <h1> elements from the menu (FWS : Why did you use the <h1> element to separate the different menu's?) and replace these with normal <p> or <strong> elements.
It's better not to use a lot of <h1> tags in your document, the <h1> is the most important "on page" element, so handle it with care and use it for your most important thing only.

2. In the header make sure the logo of your shop is in the <h1> element. Give your logo a "alt" and a "title" element. You could use your $shop_description for this and fill this description with meaningful keywords. Because your logo is in a <h1> element the alt and title element will both be seen as the title text, hence they will be seen as 'very important' by the search engine.


Well, there is a lot more to do, for instance a meaningful description on every page.

If anyone wants to discus this I'd be glad to :-)

Kind regards,

Joep

PS: If these functions are to implemented on a new version already..forget I posted this :-)





Logged
Pages: [1] 2 3   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!