How to get rendered page output within CMS

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
tbaalham
New Member
New Member
Posts: 9
Joined: Tue Dec 06, 2011 10:26 pm

How to get rendered page output within CMS

Post by tbaalham »

Does anyone know of a way to access the rendered output of a page from with the CMS libraries? I've found examples of pulling individual content blocks for a page, but nothing covering rendering of the entire output of a page.

The only option I have come up with so far is using smarty to fetch the page externally from the web server, but seeing as the CMS does the page rendering anyway, it would be desirable to access the output from within if possible.

Any pointers or suggestions appreciated.

Cheers...
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: How to get rendered page output within CMS

Post by Dr.CSS »

When you say render the whole page what exactly do you mean?...
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: How to get rendered page output within CMS

Post by Wishbone »

I think what he means is a way to fetch a string containing the HTML for the entire page, including CSS, template, etc, as opposed to fetching a particular content block.
tbaalham
New Member
New Member
Posts: 9
Joined: Tue Dec 06, 2011 10:26 pm

Re: How to get rendered page output within CMS

Post by tbaalham »

Dr CSS/Wishbone, thanks for responding.

Wishbone's comment is correct. I'm looking for a way to get the FULL content from a page programatically from within the CMS, just as if it were accessed from the web server - template applied, content and global content processed etc.

Any help appreciated.

Cheers...
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: How to get rendered page output within CMS

Post by spcherub »

Does this need to happen within your CMSMS instance? If not, have you considered an offline spidering tool or using curl to access and save your page contents?

Just curious - what is the use case?

S
tbaalham
New Member
New Member
Posts: 9
Joined: Tue Dec 06, 2011 10:26 pm

Re: How to get rendered page output within CMS

Post by tbaalham »

Sorry, I should have provided a little more context.

Basically I am trying to work out a way to provide templated reusable content within the CMS. Normally I would use GCBs, but there is no way to provide a templated view for GCBs which end user editors can work with.

So the idea is to create a bunch of hidden pages on the site, and then reuse the rendered content from these pages to embed in other pages.

Cheers...
mcDavid
Power Poster
Power Poster
Posts: 377
Joined: Tue Mar 31, 2009 8:45 pm
Location: Delft, Netherlands

Re: How to get rendered page output within CMS

Post by mcDavid »

tbaalham wrote:Sorry, I should have provided a little more context.

Basically I am trying to work out a way to provide templated reusable content within the CMS. Normally I would use GCBs, but there is no way to provide a templated view for GCBs which end user editors can work with.
How do you mean "there is no way to provide a templated view for GCB's"?
Global content blocks use the same template engine as all other templates in CMS Made Simple. And they're edittable with the same wysiwyg editor if you want to. You can give every user rights to edit content blocks. I really don't see the problem?
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: How to get rendered page output within CMS

Post by spcherub »

Also if you use the CGSimpleSmarty module, you can grab content (and even content blocks) from other pages at source instead of rendered HTML. SO in your case you can have the hidden pages that authors can edit and preview to make sure it looks like what they need. Then you can use the functions built into CGSimpleSmarty to grab content from these pages and display on other public pages. It is that simple.
tbaalham
New Member
New Member
Posts: 9
Joined: Tue Dec 06, 2011 10:26 pm

Re: How to get rendered page output within CMS

Post by tbaalham »

Thanks spcherub. I've checked out CGSimpleSmarty, but as far as I can tell, I can only pull out the content elements from a given page, not the full content including the template content.

e.g. say my page template is as follows:

<div class="bob">{content}</div>

From what I understand CGSimpleSmarty will let me access the value for the {content} block, but not the code (<div> etc.) around it.

Cheers...
mcDavid
Power Poster
Power Poster
Posts: 377
Joined: Tue Mar 31, 2009 8:45 pm
Location: Delft, Netherlands

Re: How to get rendered page output within CMS

Post by mcDavid »

again, why don't you just use GCB's for this?

You can also nest GCB's in GCB's so you can make one "template" GCB with a "content" GCB nested in it.
tbaalham
New Member
New Member
Posts: 9
Joined: Tue Dec 06, 2011 10:26 pm

Re: How to get rendered page output within CMS

Post by tbaalham »

Hi, the reason I can't use GCBs is that there is no option with GCBs to offer only part of the content block for editing by an Editor user. I want to template all of the complicated bits, and let the user just fill in the required information, just like they do with a page.

If there is a way I can programatically extract the rendered output from a page, then I can achieve what I am trying to do. I am currently trolling through the API docs, but if someone knows how to do this, that would be great.

Thanks!
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: How to get rendered page output within CMS

Post by spcherub »

How about using CGSimpleSmarty to get the content as it was designed to do, but repeat the surrounding template code where you reuse the content. So in your example from above, if the source page is something like this...

Code: Select all

<div class="parent">
<div class="child">
{content block="custom_block"}
</div>
</div>
Then where you use the content in a public way could be something like this...

Code: Select all

<div class="parent">
<div class="child">
{$cgsimple->get_page_content('private','custom_block','foo')}{eval var=$foo}
</div>
</div>
If you use the same stylesheets in both templates then the end result will be what you want to happen (assuming I comprehend your requirement). You can repeat this for each of the blocks of content.

-S
Post Reply

Return to “Developers Discussion”