Search Friendly URLs

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 8, 2008   (RSS)

Re: [Glasairmell] Search Friendly URLs

By Dave - February 8, 2008

Hi Glasairmell,

Let's see if I can answer all those questions, let me know if I miss one or if I can provide more detail.

>Broken links with useSeoUrls

I think this is the same as a glitch I found last night. When your viewer is in the root of the website it puts two slashes in front of the url and the browser links to it like this: http://products.php which of course doesn't work. It's fixed for the next version, here's the fix if you want to apply it yourself.

Open lib/viewer_functions.php search for "get absolute url" and replace this:

// get absolute url for viewer
if (@$options['useSeoUrls'] && @$options['viewerUrl'] && !preg_match("|[/]|", $options['viewerUrl'])) {
$options['viewerUrl'] = dirname($_SERVER['PHP_SELF']) ."/". $options['viewerUrl'];
}


with this:

// get absolute url for viewer
if (@$options['useSeoUrls'] && @$options['viewerUrl'] && !preg_match("|[/]|", $options['viewerUrl'])) {
$options['viewerUrl'] = dirname($_SERVER['PHP_SELF']) ."/". $options['viewerUrl'];
$options['viewerUrl'] = preg_replace("/\\/+/", "/", $options['viewerUrl']); // remove multiple leading /'s
}


>How can the client specify the url names?

The viewer option 'titleField' specifies a list of fields to check when creating the url. So if you create a text field called 'filename' and set 'titleField' to be "filename,title" it would use the value from the filename field unless it's blank, then it would use the value from the title field.

>Can I call from separate tables on one page?

Yes, you can have as many viewers as you need in one page. Just copy and paste multiple viewers into a page and give it a try. If the variables are overwriting each other or getting confusing you can rename them. For example you can replace all instances of $listRows with $articleRows. Or you might rename $record to be $article.

Hope that helps. Let me know if I can provide any more details.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Search Friendly URLs

Thank you, that fixed it.

I am not sure why you formated your seo urls to section.php/name-1/

To me this looks much better for SEO. section.php/name.html
however that is just little ole me talking.

Why not make it look like this using the $options['titleField'] = 'name'; function?
http://www.mellinger-co.com/products.php/Garden_Shears.html

instead of like you do it. http://www.mellinger-co.com/products.php/Garden_Shears-1/

In the viewer_functions.php file
// Mod here took away the "-"
if ($extraUrlDetails) { $extraUrlDetails .= ""; }

and changed this line
$record['_link'] = $options['viewerUrl'] . $urlDelimiter . $extraUrlDetails . ".html";

Not sure yet if I created in trouble for myself by doing that but it looks nice to me = ) Yes it is nice that you can do things the way you want with your program and thank you for that. Your forum response is excellent and you have always provided great service for Article Manager which I love dearly.

Re: [Glasairmell] Search Friendly URLs

By Dave - February 8, 2008

Glad it's working!

For the SEO urls we need something unchanging that we can use to identify the record. The dash number ("title-1") on the end is the record number we use. So even if the user changes the title - urls with the old and new titles will still work because they'll have the same record number of the end.

I know the number part isn't the nicest, but it made the most sense for general use. If you knew you were going to have a "filename" field you can make it unique and required and use that as a lookup (instead of the number) with a bit of PHP code and you wouldn't need the number.

Also, adding .html instead of the slash on the end is totally fine. I've even thought about adding an option for that, we just hadn't done it yet. Another trick you can do is to use .htaccess or mod_rewrite (on Apache) to drop the .php part of the filename so it's just /products/Garden_Shares-1.html

Best of luck with your site, let us know if you have any other questions.
Dave Edis - Senior Developer
interactivetools.com