different URLs for records

11 posts by 2 authors in: Forums > CMS Builder
Last Post: October 1, 2012   (RSS)

Re: [shawnpatoka] different URLs for records

By gregThomas - September 25, 2012 - edited: September 25, 2012

Hi,

CMS Builder does allow you to create more descriptive links fairly easily if your using the code generator to create your list page. You could create something like:

page.php?this-is-my-page-title_1

This can be done by going into your CMS builder admin area and then selecting the Section Editor. From here click modify on the section you want to better links for.

Next select the Viewer URLS tab at the top of the page. The 4th text box down labeled filename fields allows you to add fields that will appear in your URL.

If your not using the code generator let me know and I'll explain how to get the custom links manually.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] different URLs for records

Hi, Thank you for your help. But I guess I am really not sure if i am using the code generator or not. I do use it, but i just grab whatever code i need from it and put it in my different pages.

Re: [shawnpatoka] different URLs for records

i guess for seo purposes, i would love a URL specific to each record if possible. for instance, i have a list of bars, and each bar will have their own page.

so in this case...
http://seenstream.com/detail.php?=1

I would love for the URL to be...
http://seenstream.com/bars/obs-brau-haus

would that be at all possible?

Re: [shawnpatoka] different URLs for records

By gregThomas - September 26, 2012 - edited: September 27, 2012

Are you using the getRecords function and _link variable to link to the bar details page? If your using something similar to this to list your records and create the URL:

// load records from 'news'
list($newsRecords, $newsMetaData) = getRecords(array(
'tableName' => 'news',
'perPage' => '3',
'loadUploads' => true,
'allowSearch' => false,
));

?>
<?php foreach ($newsRecords as $record): ?>
<br/><a href="<?php echo $record['_link'] ?>">Read More</a><br/>
<hr/>
<?php endforeach ?>

Then the method I suggested in my first post should help create more SEO friendly URLs

If you would like a url that is something like http://seenstream.com/bars/obs-brau-haus I would create a directory in the base of your site called bars that contains all of your bar pages. Then the URL would be http://seenstream.com/bars/details.php?this-is-a-bar. You could then look into using a .htaccess to hide the php file extension (https://www.google.ca/q=remove+.php+with+htacces) so you end up with:

http://seenstream.com/bars/details?this-is-a-bar-2

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] different URLs for records

Im sorry, I just cant seem to get these URLs to work. so if i go to the contact us page... shouldnt the url just be page.php?contact_us ?

I have "title" in the filename field in the section editor in the view url tab.

Re: [shawnpatoka] different URLs for records

Hi,

Could you attach list.php to a post so that I can see exactly how your code is set up? This will also make it easier for me to show you how to set up better URLs.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] different URLs for records

hi, this is just one example of a page that i would the URL to look like shawnpatoka.com/pages.php?about-us

the actual link is... shawnpatoka.com/pages.php?=1

(excuse all of the broken links and broken images. Im in the process of moving the site over to another server to fix my database problems. )

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php


// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/nfs/c06/h05/mnt/94791/domains/shawnpatoka.com/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load record from 'pages'
list($pagesRecords, $pagesMetaData) = getRecords(array(
'tableName' => 'pages',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$pagesRecord = @$pagesRecords[0]; // get first record
if (!$pagesRecord) { dieWith404("Record not found!"); } // show error message if no record found

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title><?php echo htmlencode($pageRecord['page_title']) ?></title>
<link href='http://fonts.googleapis.com/css?family=Ubuntu:300,400' rel='stylesheet' type='text/css'>
<link href="ip_style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-34997255-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>

<body>

<!-- begin header -->
<?php include("navigation.php"); ?>
<!-- end header -->

<div id="content-container">
<div class="listings-container">
<h1><?php echo htmlencode($pagesRecord['title']) ?></h1>
<?php echo $pagesRecord['content']; ?>

</div>

<div id="ad-container"> <div class="ad-space"><a href="http://www.llsmiling.com/" target="_blank"><img src="i/lls_ad_250x250.jpg" border="0" /></a></div> </div>

<br class="clear" />

<?php include("footernav.php"); ?>
</div>

</body>
</html>

Re: [shawnpatoka] different URLs for records

Hi,

Please could you post the file that contains your navigation links as well (I'm guessing it's navigation.php)? So I can see how your creating them.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] different URLs for records

yes it is the navigation.php...

<div id="header-span">
<div id="header-container">
<div id="logo"><a href="default.php"><img src="i/ss_logo.png" /></a></div>
<a href="events.php?orderBy=date"><div id="nav-events">events</div></a>
<a href="list.php"><div id="nav-list">bar list</div></a>
<a href="page.php?=1"><div id="nav-about">about seenstream</div></a>
<a href="page.php?=2"><div id="nav-contact">contact us</div></a>
</div>
</div>
<div id="header-span-shadow"></div>
<div id="beta"></div>