Search Friendly URLs

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

When I use $options['useSeoUrls'] = '1'; it returns http://products.php/1/ which is a broken link instead of http://www.mellinger-co.com/products.php?1/ that the $options['useSeoUrls'] = ''; produces. What am I doing wrong please. Also AM produces SE friendly URLs like http://www.tradezone.com/articles/global-business/Ten_Tips_for_Translating_Your_Business_Card_16.php. for each page your create. CMS produces products.php?1/2/3 etc which definitely is not what I am looking for. The client should be able to name each page in a section the way he wants it to appear. Of course I may be missing something here since I am just learning the program.[/#333366] [/#333366] Also, can I call from separate tables on one page? $options['tableName'] = 'products'; calls from products table, how would I add the ability to call from a second table to use the fields in that table also on the same page?[/#333366] [/#333366] Thanks you for your time and efforts.[/#333366]

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: [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