Finduilas
Finduilas

Reputation: 742

Editable pages in FuelCMS

I started working with a CMS (and codeIgniter). I chose for FuelCMS because of the languages,...

So far, It works fine. I have a controller that handles the pages, the languages,..

I made an hierarchy of pages under the views:

de/page1

de/page2

uk/page1

uk/page2

But now I want to edit the specific content of that page. I have 2 blocks that I use all the time: a header and a footer. Page1 is looking like this:

<?php $this->load->view('_blocks/de/header')?>
// HERE I WANT TO GET THE EDITABLE CONTENT OF THE PAGE...
<?php $this->load->view('_blocks/de/footer')?>

But it"s not clear to me how I can get the page in the fuelCMS. If I make them directly in the CMS to test a while ago it worked. But then I can't work with my custom controller.

How can I show the pages in the CMS and only let them edit the content-part of my page?

Upvotes: 0

Views: 170

Answers (1)

LGH
LGH

Reputation: 66

I don't follow your question 100% but I'll try to help. Assuming you're using version 1.0 and you want to have editable layouts under "pages" in the admin interface.

The first thing you'll want to do is open up /fuel/config/MY_fuel.php and add these:

// languages for pages. The key is saved to the page variables
$config['languages'] = array(
    'en' => 'English',
    'de' => 'Dutch'
);

$config['language_mode'] = 'segment';

Then, open up /fuel/config/MY_fuel_layouts.php and create a layout. Here's a basic one:

# Common meta
$common_meta = [
    'meta' => [
        'type'  => 'fieldset',
        'label' => 'Meta',
        'class' => 'tab'
    ],
    'meta_section' => [
        'type'  => 'copy',
        'label' => 'The following fields control the meta information found in the head of the HTML.'
    ],
    'body_class' => [],
    'page_title' => [
        'label' => lang('layout_field_page_title'),
        'description' => 'This displays at the very top of the browser bar.'
    ],
    'meta_description' => [
        'style' => 'width: 520px',
        'label' => lang('layout_field_meta_description')
    ],
    'meta_keywords' => array(
        'style' => 'width: 520px',
        'label' => lang('layout_field_meta_keywords')
    ]
];

# Common content
$common_content = [
    'common_content' => [
        'type'  => 'fieldset',
        'label' => 'Content',
        'class' => 'tab'
    ],
    'page_heading' => array(
        'label' => 'Page heading',
        'description' => 'This displays at the top of the page in the content'
    ],
    'body' => array(
        'label' => lang('layout_field_body'),
        'type'  => 'textarea',
        'description' => lang('layout_field_body_description')
    ]
];

$main_layout = new Fuel_layout('main');
$main_layout->set_description('This is the layout for most pages.');
$main_layout->set_label('Main');
$main_layout->add_fields($common_content);
$main_layout->add_fields($common_meta);

Make sure you've got a file called main.php in /fuel/application/views/_layouts

When you head to pages/create in FUEL, you'll see an "language" select under the layout one in the top of the page. That is how you set the different language content for the same layout.

This is how these two pages are made: http://impression.co.nz/sell http://impression.co.nz/ch/sell

If you still need a controller to intercept, you can render a cms page from a controller with:

$this->fuel->pages->render('url', [], ['render_mode' => 'cms']);

Where url is your "location" value in the admin and the empty array is some vars you may want to pass it.

Does that help? or way off?

Upvotes: 0

Related Questions