Permalink Derived Query String?
2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 23, 2014 (RSS)
By Perchpole - July 21, 2014
Hello, All
I am trying to integrate Permalinks into an older CMSB set-up and have come up against a problem. Much of the design and interactivity relies upon a query string passing the page number back to CMSB.
index.php?page=3
In this instance the query string page=3 tells the system which template and which content to load.
If I use Permalinks, on the other hand, there is no query string - so no page number - and the whole system falls flat.
Is there an ingenious way for to derive the page number without a query string?
:0/
Perch
By claire - July 23, 2014
Hey Perch
There is a way to do this, but it depends on you creating a permalink specifically for each page, which may not be feasible. I had to do something similar to this last week for another site and this is what I went with:
Create a new section called Pages, and add the permalink fields to each. Then for each page, create an appropriate permalink, like say http://www.example.com/page3 for the third record, http://www.example.com/page4 for the fourth, etc. Go to the Section Editor, and set the detail page for this section to be the index.php or whatever viewer uses the page=3 thing.
In the Code Generator, create a detail page for this section and tick this option: Get record # from end of url. eg: viewer.php?record_title-3
So now the generated code will look something like this:
list($exampleRecords, $exampleMetaData) = getRecords(array(
'tableName' => 'example_table',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$exampleRecord = @$exampleRecords[0]; // get first record
Include this in your viewer before the code that does something with $_REQUEST['page'].
Basically what happens now is that this permalink - http://www.example.com/page3 - goes to your viewer and automagically delivers the Pages record as $exampleRecord. You can then use the $exampleRecord['num'] value anywhere you'd use $_REQUEST['page'].
You don't even need to use getRecords here but I'm including it for simplicity.
This will only work if you have a set number of pages, though. Hope it helps.
Claire Ryan
interactivetools.com
Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/