Permalinks

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

By gregThomas - February 4, 2013

Hi Greg,

This is possible, and should be fairly straight forward to do. You can use a getRecord function to get the record number from the URL and get the appropriate record.

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

Let me know if you have any other questions on setting up this system. 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gversion - February 4, 2013

Hi Greg,

Thanks for your response. I have inserted the code you provided into "page.php".

Can you give me an example of how I set up a link please?

I would like to display the content of the "About" record, which can be accessed at "/page.php?num=1" with the URL "/about.php".

I am not clear on how to change the filename from "page.php?num=1" to "about.php"? Do I need to use .htaccess to achieve this?

Thanks,

Greg

By gregThomas - February 4, 2013

Hi Greg,

You could create a list of links to the individual pages like this:

// load records from 'web_pages'
list($links, $linkMetaData) = getRecords(array(
'tableName' => 'web_pages',
'loadUploads' => true,
'allowSearch' => true,
));

?>


<?php foreach($links as $link): ?>
  <a href="page.php?<?php echo urlencode($link['title']).'-'.$link['num']; ?>" ><?php echo $link['title']; ?></a><br/>
<?php endforeach;


?>

You would need to create the individual htaccess rules if you want to change the name of the page that appears in the URL. If you look at my post on this thread:

http://www.interactivetools.com/forum/forum-posts.php?Writing-friendly-URLs-with-.htaccess-INFORMATION-ONLY-78451

I've added a link to a site that will generate the rules for you. Although you could also try using the system suggested by zaba.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gversion - February 4, 2013

Hi Greg,

Mnay thanks for your help. I am now up and running.

Regards,

Greg