Thread: [Cppcms-users] render sub-template without parents
Brought to you by:
artyom-beilis
|
From: bibermann <fab...@gm...> - 2014-10-15 14:45:16
|
Hello, I'm going to use CppCMS for an Ajax-driven site and am wondering whether it's possible to only return the HTML for a sub-template. Considering the example given in http://cppcms.com/wikipp/en/page/cppcms_1x_tut_templates_inheritance where we have the following template hierarchie: master / | \ news page intro I want to be able to both render the news normally and as part of an ajax request to update the news item without reloading the full page, i.e. returning page_content() of this template. Can I achieve this functionality with CppCMS or do I need to create two version of "news"? Thanks in advance, bibermann |
|
From: Lee E. <le...@el...> - 2014-10-15 22:49:16
|
Template hirarchi translates to class hirarchi, with methods You can call the news method from two templates, one as part of a full page and another as partial בתאריך 15 באוק 2014 17:45, "bibermann" <fab...@gm...> כתב: > Hello, > > I'm going to use CppCMS for an Ajax-driven site and am wondering whether > it's > possible to only return the HTML for a sub-template. > > Considering the example given in > http://cppcms.com/wikipp/en/page/cppcms_1x_tut_templates_inheritance > where we have the following template hierarchie: > master > / | \ > news page intro > I want to be able to both render the news normally and as part of an ajax > request to update the news item without reloading the full page, i.e. > returning page_content() of this template. > > Can I achieve this functionality with CppCMS or do I need to create two > version of "news"? > > Thanks in advance, > bibermann > > > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
|
From: bibermann <fab...@gm...> - 2014-10-20 12:12:14
|
Lee Elenbaas <lee@...> writes: > > > Template hirarchi translates to class hirarchi, with methods > You can call the news method from two templates, one as part of a full page and another as partial > בתאריך 15 באוק 2014 17:45, "bibermann" <fabianvss- Re5...@pu...> כתב:Hello, > I'm going to use CppCMS for an Ajax-driven site and am wondering whether it's > possible to only return the HTML for a sub-template. > Considering the example given inhttp://cppcms.com/wikipp/en/page/cppcms_1x_tut_templates_inheritance > where we have the following template hierarchie: > master > / | \ > news page intro > I want to be able to both render the news normally and as part of an ajax > request to update the news item without reloading the full page, i.e. > returning page_content() of this template. > Can I achieve this functionality with CppCMS or do I need to create two > version of "news"? > Thanks in advance, > bibermann > -------------------------------------------------------------------------- ---- > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device.http://p.sf.net/sfu/Zoho > _______________________________________________ > Cppcms-users mailing listCppcms-users- 5NW...@pu...://lists.sourceforge.net/lists /listinfo/cppcms-users > > > > > -------------------------------------------------------------------------- ---- > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > > -------------------------------------------------------------------------- ---- > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho Sorry, I did not understand. Which function do you mean? I think I cannot access the News instance from within the Code. If this does not work I would linke to somehow include a separate template (like #include but at template-compile time - I didn't found a possibility to do this). Regards, bibermann |
|
From: Artyom B. <art...@ya...> - 2014-10-20 12:31:48
|
Think this
you have a template that generates some interesting content
<% view some_view uses page_content %>
<% template page_content() %>
...
<% end template %>
<% end view %>
Lets derive a new template
<% view page_content_only uses page_content extends some_view %>
<% template render() %>
<% include page_content() %>
<% end template %>
<% end view %>
Now you can render "page_content_only" view that would create what you need.
{
...
render("page_content_only",c);
...
}
Thinks of classes and inheritance.
You can also use "helpers" concept and generate a separate view that only
generates a page_content and use it in various places:
http://cppcms.com/wikipp/en/page/cppcms_1x_templates_comm#Views.Helpers
Artyom Beilis
--------------
CppCMS - C++ Web Framework: http://cppcms.com/
CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
----- Original Message -----
> From: bibermann <fab...@gm...>
> To: cpp...@li...
> Cc:
> Sent: Monday, October 20, 2014 2:11 PM
> Subject: Re: [Cppcms-users] render sub-template without parents
>
> Lee Elenbaas <lee@...> writes:
>
>>
>>
>> Template hirarchi translates to class hirarchi, with methods
>> You can call the news method from two templates, one as part of a full
> page and another as partial
>> בתאריך 15 באוק 2014 17:45, "bibermann" <fabianvss-
> Re5...@pu...> כתב:Hello,
>> I'm going to use CppCMS for an Ajax-driven site and am wondering
> whether
> it's
>> possible to only return the HTML for a sub-template.
>> Considering the example given
> inhttp://cppcms.com/wikipp/en/page/cppcms_1x_tut_templates_inheritance
>> where we have the following template hierarchie:
>> master
>> / | \
>> news page intro
>> I want to be able to both render the news normally and as part of an ajax
>> request to update the news item without reloading the full page, i.e.
>> returning page_content() of this template.
>> Can I achieve this functionality with CppCMS or do I need to create two
>> version of "news"?
>> Thanks in advance,
>> bibermann
>> --------------------------------------------------------------------------
> ----
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.http://p.sf.net/sfu/Zoho
>> _______________________________________________
>> Cppcms-users mailing listCppcms-users-
> 5NW...@pu...://lists.sourceforge.net/lists
> /listinfo/cppcms-users
>>
>>
>>
>>
>> --------------------------------------------------------------------------
> ----
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>>
>> --------------------------------------------------------------------------
> ----
>> Comprehensive Server Monitoring with Site24x7.
>> Monitor 10 servers for $9/Month.
>> Get alerted through email, SMS, voice calls or mobile push notifications.
>> Take corrective actions from your mobile device.
>> http://p.sf.net/sfu/Zoho
>
>
> Sorry, I did not understand. Which function do you mean? I think I cannot
> access the News instance from within the Code.
>
> If this does not work I would linke to somehow include a separate template
> (like #include but at template-compile time - I didn't found a possibility
> to do this).
>
> Regards,
> bibermann
>
>
> ------------------------------------------------------------------------------
> Comprehensive Server Monitoring with Site24x7.
> Monitor 10 servers for $9/Month.
> Get alerted through email, SMS, voice calls or mobile push notifications.
> Take corrective actions from your mobile device.
> http://p.sf.net/sfu/Zoho
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
|
|
From: Lee E. <le...@el...> - 2014-10-21 07:54:14
|
take a look at the generated c++ code generate from a template - you will see how a template can inherit from another, and override it i am not free to take a look myself right now, i will try to give a more complete answer later On Mon, Oct 20, 2014 at 3:11 PM, bibermann <fab...@gm...> wrote: > Lee Elenbaas <lee@...> writes: > > > > > > > Template hirarchi translates to class hirarchi, with methods > > You can call the news method from two templates, one as part of a full > page and another as partial > > בתאריך 15 באוק 2014 17:45, "bibermann" <fabianvss- > Re5...@pu...> כתב:Hello, > > I'm going to use CppCMS for an Ajax-driven site and am wondering whether > it's > > possible to only return the HTML for a sub-template. > > Considering the example given > inhttp://cppcms.com/wikipp/en/page/cppcms_1x_tut_templates_inheritance > > where we have the following template hierarchie: > > master > > / | \ > > news page intro > > I want to be able to both render the news normally and as part of an ajax > > request to update the news item without reloading the full page, i.e. > > returning page_content() of this template. > > Can I achieve this functionality with CppCMS or do I need to create two > > version of "news"? > > Thanks in advance, > > bibermann > > > -------------------------------------------------------------------------- > ---- > > Comprehensive Server Monitoring with Site24x7. > > Monitor 10 servers for $9/Month. > > Get alerted through email, SMS, voice calls or mobile push notifications. > > Take corrective actions from your mobile device.http://p.sf.net/sfu/Zoho > > _______________________________________________ > > Cppcms-users mailing listCppcms-users- > 5NW...@pu...:// > lists.sourceforge.net/lists > /listinfo/cppcms-users > > > > > > > > > > > -------------------------------------------------------------------------- > ---- > > Comprehensive Server Monitoring with Site24x7. > > Monitor 10 servers for $9/Month. > > Get alerted through email, SMS, voice calls or mobile push notifications. > > Take corrective actions from your mobile device. > > http://p.sf.net/sfu/Zoho > > > > > -------------------------------------------------------------------------- > ---- > > Comprehensive Server Monitoring with Site24x7. > > Monitor 10 servers for $9/Month. > > Get alerted through email, SMS, voice calls or mobile push notifications. > > Take corrective actions from your mobile device. > > http://p.sf.net/sfu/Zoho > > > Sorry, I did not understand. Which function do you mean? I think I cannot > access the News instance from within the Code. > > If this does not work I would linke to somehow include a separate template > (like #include but at template-compile time - I didn't found a possibility > to do this). > > Regards, > bibermann > > > > ------------------------------------------------------------------------------ > Comprehensive Server Monitoring with Site24x7. > Monitor 10 servers for $9/Month. > Get alerted through email, SMS, voice calls or mobile push notifications. > Take corrective actions from your mobile device. > http://p.sf.net/sfu/Zoho > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |