Jump to content

Front End Edit with ->render


Tom Walcher
 Share

Recommended Posts

I tryed 

foreach($modules->children as $module) {

    $filename = dirname(__FILE__) . "/".$module->template;
    $t = new TemplateFile($filename);
    $t->set('page', $module);
   echo $t->render();
}

 

but still no editor.

I think it does know the template, or because its a repeater, just new with this.

 

Link to comment
Share on other sites

Front-end editing works okay for me when using $page->render(). If you are using "Option A" for front-end editing make sure you have selected "Fields editable regardless of page".

But a couple of observations:

1. Do you really need to be rendering pages? Can you not just get your pages into a PageArray and iterate over them, echoing the fields you want?

$items = $pages->find("template=my_template");
foreach($items as $item) {
    echo "<h3>$item->title</h3>";
    echo $item->body;
    // etc
}

If you're sure you need to render you might be better off using $files->render() as it is better documented than $page->render().

2. In your code...

On 14/10/2016 at 4:10 AM, Tom Walcher said:

foreach($modules->children as $module) {

    $filename = dirname(__FILE__) . "/".$module->template;
    $t = new TemplateFile($filename);
    $t->set('page', $module);
   echo $t->render();
}

...you are overwriting the core API $modules variable. You should choose a different name for your variable.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...