Jump to content

Get rendered output of page programatically - useMarkupRegions


baronmunchowsen
 Share

Recommended Posts

I'm trying to get the rendered output of a page in a custom module.

In my custom Process module, I have the following:

public function ___execute() {
  $page = $this->pages->get(1);
  $page->of(true);
  $op = $page->render();
  return "Hello World";
}

An exception is thrown:

Quote

ProcessWire\WireException
Method Pageimage::srcset does not exist or is not callable in this context

The srcset functionality is used liberally to generate the desired output of a page.

Any suggestions on what I can do to avoid the srcset error?

Edit 1: using MarkupSrcSet module: https://processwire.com/modules/markup-src-set/ - which adds the srcset method in it's ready() function. Is it possible to boostrap this prior to calling the render() function?

Edit 2: bypassed the issue specific to the srcset above, it further appears that rendering output is problematic when using MarkupRegions. Title updated and tagged accordingly. Can anyone provide insight into how to retrieve the output of a page using markup regions in the template layer?

Link to comment
Share on other sites

16 hours ago, baronmunchowsen said:

ProcessWire\WireException
Method Pageimage::srcset does not exist or is not callable in this context

This exception says that it has found something that was expected to be a object of type pageimage but maybe it is not what can be the case if there is a empty pageimage field in your template and you have not a check for that in your template file, so simply calling pageimage::srcset on an empty object (null).

First you should inspect your involved page and template about this. If you find that there is a valid pageimage object (with available image object) that triggers this exception, you must find out why the srcset method isn't known at this state. But I would go first step first. Mostly there is no second step needed after it.  ?

 

 

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

×
×
  • Create New...