Get a combined list of CMS and Static Pages
3
Sometimes it is necessary to assign a model to a specific page. Just add a simple dropdown to your fields.yaml
:
basefile:
label: 'Associated Page'
span: auto
type: dropdown
And the following code to your model:
public function getBasefileOptions()
{
// get default pages
$pages = \Cms\Classes\Page::sortBy('baseFileName')->lists('title', 'baseFileName');
// also add static pages if the Pages plugin is installed.
if (class_exists('\\Rainlab\\Pages\\Classes\\Page')) {
$pages = $pages + \Rainlab\Pages\Classes\Page::sortBy('title')
->lists('title', 'baseFileName');
}
return $pages;
}
In the backend the user gets a dropdown with all CMS- and Static-Pages and saving the record the associated filename will be saved.
How can I redirect at front ? I want to redirect properly with full url .. can you please provide me twig redirection for page redirect ?