Page 1 of 1
Module/Addon to extract rendered HTML
Posted: Wed Aug 19, 2015 9:15 pm
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
Re: Module/Addon to extract rendered HTML
Posted: Wed Aug 19, 2015 9:56 pm
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.
Re: Module/Addon to extract rendered HTML
Posted: Wed Aug 19, 2015 10:28 pm
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
Re: Module/Addon to extract rendered HTML
Posted: Wed Aug 19, 2015 10:36 pm
by spcherub
@Calguy: Can I not use cge_cached_url directly instead of wrapping cge_cache around fetch?
Re: Module/Addon to extract rendered HTML
Posted: Wed Oct 21, 2015 3:14 pm
by maetmar
Hi spcherub,
did you find a solution to your problem in the meantime?
I would like to do the same thing.
thanks
Re: Module/Addon to extract rendered HTML
Posted: Fri Oct 23, 2015 12:05 pm
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
Re: Module/Addon to extract rendered HTML
Posted: Thu Oct 29, 2015 7:52 pm
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