Module/Addon to extract rendered HTML

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Module/Addon to extract rendered HTML

Post by spcherub »

Sorry about the obtuse subject line, but here's what I am seeking advice on.

I'm trying to implement a system that allows a page editor to create pages based on pre-existing visual "modules". What I've done is create a page template for each of these module (since they may have different properties). I also created a master page container template which is create the actual "page" viewed by the end-user. The author simply creates child pages based on the visual module templates - something like this:

Code: Select all

Container Page
- Sub-page 1
- Sub-page 2
- Sub-page 3
And the master (container) page assembles the final view using this simple menu loop:

Code: Select all

{foreach from=$nodelist item=node}
{fetch file=$node->url}
{/foreach}
This works for testing, but is not efficient as it results in a server round trip to pull the code for each sub-page. So my question is... is there a module/addon that allows me to pass it a page_id and have it return the rendered HTML markup (the same markup returned by the page if it were being viewed by a browser).

If this explanation does not make sense, I can try and give more content.

TIA
-Sanjay
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Module/Addon to extract rendered HTML

Post by calguy1000 »

I think you are attacking a simple problem using a rube-goldberg machine.

You need to read, research and learn about template inheritance. which allows you to create N different page templates that all have similar appearance but with different amount of content blocks... and they all have the same properties. I think you would get this problem solved in a few hours by implementing template inheritance.

That said. if you want to be able to support N blocks instead of just 3, and you want the 'editor' (who is at this point just doing design work... just sayin) to just add N pages below a 'master' page and have the child content pulled into the master then you could use the {cge_cache} plugin in CGExtensions along with the {fetch} plugin.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Module/Addon to extract rendered HTML

Post by spcherub »

Thanks Calguy for your frank assessment. I will look right away into the cge_cache function.

In the meantime, I was thinking about my request and realize was I was really asking was is there a replacement for the {fetch} tag that does not result in a server roundtrip (just does a local db lookup and processing). Or is that how the fetch tag works anyway?

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

Re: Module/Addon to extract rendered HTML

Post by spcherub »

@Calguy: Can I not use cge_cached_url directly instead of wrapping cge_cache around fetch?
maetmar
Forum Members
Forum Members
Posts: 36
Joined: Wed Oct 25, 2006 7:48 pm

Re: Module/Addon to extract rendered HTML

Post by maetmar »

Hi spcherub,
did you find a solution to your problem in the meantime?
I would like to do the same thing.

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

Re: Module/Addon to extract rendered HTML

Post by spcherub »

@maetmar - no I did not find my optimal solution yet and just kept my original (suboptimal) code that I posted earlier in this thread. In this particular case, performance was not an issue (internal utility), but I will continue looking for a better solution in case I have to build a more public site where performance will be a consideration.

My search stems from the fact that there is obviously code within the system that "renders" a page for output based on alias/id, so there should be an easy way to tap into this (kind of an include-rendered-page-code tag if you will). I don't have the PHP skills to dive that deep into the core, otherwise would have tried to create such a tag/UDT.

-S
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm

Re: Module/Addon to extract rendered HTML

Post by rotezecke »

in CGSimpleSmarty there's:

{cgsimple::get_page_content('about','second','foo')}{eval var=$foo}

Note: assign parameter dropped in CMSMS 2.0
{$foo = "{cgsimple::get_page_content('about','second')"}{eval var=$foo}

where cgsimple::get_page_content does the fetching, and eval the rendering.

http://www.smarty.net/docsv2/en/languag ... n.eval.tpl
Post Reply

Return to “Modules/Add-Ons”