• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: [SOLVED] How to change template while RegisterRoute?
PostPosted: Fri Mar 23, 2012 9:22 pm 
Offline
Forum Members
Forum Members

Joined: Wed Feb 22, 2012 9:13 pm
Posts: 13
Hello all!

I wonder if some one know how to assign some template for route.

I was try that:

Code:
$this->RegisterRoute('@some/place/(?P<paramname>.*?)$@', array('action'=>'custom_action', 'showtemplate='=>'NotDefaultTemplate'));


but with out some success. Do not wont to change some core logics but it seems that no way to say which template use in route setup or later in action.custom_action.php, am i missing some?


Last edited by kembl on Mon Mar 26, 2012 10:55 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Fri Mar 23, 2012 9:49 pm 
Offline
Dev Team Member
Dev Team Member
User avatar

Joined: Tue Oct 19, 2004 6:44 pm
Posts: 6609
Location: Fernie British Columbia, Canada
'showtemplate' is reserved to disable the output of the cmsms page template, and just return the results of the {content} block.

Assuming your action understood the 'mytemplate' parameter (and you had set it's type with SetParameterType... you could use:

Code:
$this->RegisterRoute('@some/place/(?P<paramname>.*?)$@', array('action'=>'custom_action', 'mytemplate='=>'NotDefaultTemplate'));

_________________
Follow me on twitter
--
if you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
----------------
Don't make me angry..... you won't like me when I'm angry....


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Fri Mar 23, 2012 11:04 pm 
Offline
Forum Members
Forum Members

Joined: Wed Feb 22, 2012 9:13 pm
Posts: 13
calguy1000 wrote:
Assuming your action understood the 'mytemplate' parameter (and you had set it's type with SetParameterType... you could use:

Code:
$this->RegisterRoute('@some/place/(?P<paramname>.*?)$@', array('action'=>'custom_action', 'mytemplate='=>'NotDefaultTemplate'));


Thx for the fast answer!

This is main clue, I cant found (in documentation and forum) how to change curent page template "on the fly" from module code. So even if I got NotDefaultTemplate in "custom_action", I duno how to ask the CMS to use new template (by name or id) which listed in CMS templates.

In current time all routed sites use template from the page which marked as default in admin interface.


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Sat Mar 24, 2012 9:48 pm 
Offline
Forum Members
Forum Members

Joined: Wed Feb 22, 2012 9:13 pm
Posts: 13
Hello all, today :)

After several cup of coffe, I almost found the way to set up differetn from default template for a page after RegisterRoute, without any changes in core CMS algorithm.

Lets see this beautiful workaround:

In the top of your action.custom_action.php ( this name only for example), you need to add:
Code:
$content_obj = $gCms->variables['content_obj'];
$content_obj->LoadFromId(63);


where 63 is the PageId with desired template on it, this id you can see in admin panel where all site pages exists.

One little devil >:D still exists: if you need total empty page after RegisterRoute, for example, to out some ajax response, you cannot achive it with explaned aproach.
Cause, even with totaly empty template and empty style for this template, and no meta and etc., I still got

Code:
<body>
<!-- start content -->


in a top of blank page... I wonder if some one know how to clean up this last two annoing strings to achieve best controlled results???


Last edited by kembl on Sun Mar 25, 2012 5:31 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Sat Mar 24, 2012 11:51 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jan 29, 2007 4:47 pm
Posts: 426
Code:
<body>
<!-- start content -->
Has to come from the template... The code itself (core) doesn't post content, just provides methods to post it, or present it, IIRC...
Same should happen with modules, unless you fetch contents from other sources other than DB. Still there must be explicit tags on a template, otherwise an empty template is just that: an empty template.

Also make sure you have cleared the cache before you test your code output.

PS: AFAIK a {content} tag must exist at all times on a template, otherwise you will get some errors...

_________________
"There are 10 types of people in this world, those who understand binary... and those who don't."

* by the way: English is NOT my native language (sorry for any mistakes...).

My developer Page on the Forge.


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Sun Mar 25, 2012 12:27 am 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 3653
Location: The Netherlands
I guess you should read Calguy's post more carefully

_________________
Get nice guestbook messages from your site visitors with the brand new Gbook module.
Integrate Piwik Web Analytics in your site admin with the Piwik module.
Extend your global site settings with the Custom Global Settings module.
The Fourth Dutch CMS Made Simple Workshop on April 9 2011 was great fun! Read all about it here
Announcement: The Fifth Dutch CMS Made Simple Workshop coming up?


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Sun Mar 25, 2012 6:26 pm 
Offline
Forum Members
Forum Members

Joined: Wed Feb 22, 2012 9:13 pm
Posts: 13
Jos wrote:
I guess you should read Calguy's post more carefully


His answer has no sense for me, cause even if I got NotDefaultTemplate variable with template name in my action, I still not know how to ask system use template with that name when out page {content} block :(

Thax Jo Morg, it was my fault, I really found those strings in one template. Any way, I found on this forum approach to disable template processing through this code

Code:
$this->RegisterRoute('@some/place/(?P<paramname>.*?)$@', array('action'=>'custom_action', 'showtemplate' => 'false'));


the quotas around false did the thing :) this is funny :o :)

Meanwhile, still cant to show routed pages with its own templates. Is this really useless thing to implement it some way without hack the core? ¯\(°_o)/¯


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Mon Mar 26, 2012 8:19 pm 
Offline
Forum Members
Forum Members

Joined: Thu Mar 08, 2012 10:51 pm
Posts: 11
Hi, I am experiencing the same problem. When I open the link registered in the module's registerRoute method, the new page uses template which is set for homepage. I cannot understand this behaviour, I would like to set another layout template for the page. But obviously I am missing something...thanks in advance for any clues guys!


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Mon Mar 26, 2012 9:37 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jan 29, 2007 4:47 pm
Posts: 426
Just by searching a bit:
one explanation....
If you take some more time to search deeper you will probably find more answers to your question. Also there is an API: you can consult it's DOC's here. Click on Class CMSModule methods...

HTH! ;)

_________________
"There are 10 types of people in this world, those who understand binary... and those who don't."

* by the way: English is NOT my native language (sorry for any mistakes...).

My developer Page on the Forge.


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Mon Mar 26, 2012 10:43 pm 
Offline
Forum Members
Forum Members

Joined: Thu Mar 08, 2012 10:51 pm
Posts: 11
Since now I am using process template method to display module content (if it were that one you were trying to hint me). My aim is to be able to display another layout template. Were you suggesting to use this method to use the layout template?


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Mon Mar 26, 2012 10:54 pm 
Offline
Forum Members
Forum Members

Joined: Wed Feb 22, 2012 9:13 pm
Posts: 13
Oh my God, Jo Morg, I was tried this, and you are the best!!! This is exactly what i need :)

I use CMS not first day, but this task was not solved by me, because I did not clear understood the docs! In my mind returnid have slight other meaning :)

Jo Morg, since this forum has no "Thanks mod", I cant fix your win official, but you stay in my hart :) and my mood goes better.

Any way, I'll mark this topic as:

......*☆.¸.☆*'
.....*☆.@@ ☆*'
...*☆.@@@@☆*'
....@SOLVED@
...☆*@@@@`*☆.¸¸
.......\\\||///.
........\\||//.
.........ƸӜƷ.
..........\|/..♥
...........V....


Top
 Profile  
 
 Post subject: Re: How to change template while RegisterRoute?
PostPosted: Mon Mar 26, 2012 10:57 pm 
Offline
Power Poster
Power Poster

Joined: Mon Jan 29, 2007 4:47 pm
Posts: 426
@kembl: thanks. Glad I could help. :)

@xlilien: Maybe (not sure if there are other ways) a different page with a different template attached to it and set this page ID as a returnID on the module (may be set on the module preferences, or as a tag parameter). Just a suggestion though.
The way most modules use to change templates is to generate their own templates, which can be administered from their own DB entries on the backend. There may be different approaches though, if I understand what you need correctly.

_________________
"There are 10 types of people in this world, those who understand binary... and those who don't."

* by the way: English is NOT my native language (sorry for any mistakes...).

My developer Page on the Forge.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
A2 Hosting