[SOLVED] Magic query parameter to skip template processing

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

[SOLVED] Magic query parameter to skip template processing

Post by spcherub »

In the early days of CMSMS there was a query parameter, which if passed to any URL (served by the CMS) would skip the processing of the template and simply return the content of the main {content} tag. Is this still supported in current versions, specifically 1.12 and 2.0? And if so, can someone remind me what this parameter is?

TIA,
Sanjay
Last edited by spcherub on Sat Sep 12, 2015 1:09 pm, edited 1 time in total.
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Magic query parameter to skip template processing

Post by spcherub »

For context, what I'm trying to do is implement a system where when a query parameter is passed to the page, it controls the way the template is processed. I tried something like this...

Code: Select all

{if $smarty.get.switch != 1}
<__html>
<head>...</head>
...
</__html>
{else}
Show this text
{/if}
But this throws an "unclosed {else} tag" smarty error.

Any suggestions on if/how this can be achieved?

Thanks,
Sanjay
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Magic query parameter to skip template processing

Post by velden »

Code: Select all

?showtemplate=false
I've been doing the same before I guess (used: here). Part of the rendered templates including content can be retrieved using ajax requests. But if the same url is used for a normal http get request (e.g. search engine result) it serves a complete html page.

Code: Select all

{title assign='title'}
{process_pagedata}
{$articleOnly=false}
{if $smarty.post.ajaxRequest == 'true'}{$articleOnly=true}{/if}
{$htmltxt='html'}
{$headtxt='head'}
{$bodytxt='body'}
content assign='content'}

{if !$articleOnly}
<!doctype html>
<{$htmltxt}>
  <{$headtxt}>
     {**}
  </{$headtxt}>

  <!--Body-->
  <{$bodytxt}>
  	<div id="pt-main" class="pt-perspective">
{/if}      
{*start of article*}
      <article>
  
      </article>
{*End of article*}
{if !$articleOnly}	  
		</div>
    <!-- jQuery -->
    <__script__ src="{root_url}/static/templates/metrika/js/jquery.js"></__script>
  </{$bodytxt}>
</{$htmltxt}>
{/if}
Not sure if it's the best way to do it but it works. Use at your own discretion. You need to 'trick' smarty to NOT recognize the <__html>, <head> and </__body> sections.
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Magic query parameter to skip template processing

Post by spcherub »

@veiden: thanks for the sample code. I did figure out that the head tag needed to be included indirectly. I ended up using a GCB.
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: Magic query parameter to skip template processing

Post by Jeff »

Code: Select all

?showtemplate=false
Will return only the {content} block as you requested.
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: Magic query parameter to skip template processing

Post by spcherub »

@Jeff - thank you so much. That is exactly what I was looking for.

For my future reference, where can I find reference to this in the documentation? I looked before I asked this time, but may not have ben looking in the right places.

Thanks,
Sanjay
Jeff
Power Poster
Power Poster
Posts: 961
Joined: Mon Jan 21, 2008 5:51 pm

Re: [SOLVED] Magic query parameter to skip template processi

Post by Jeff »

Post Reply

Return to “CMSMS Core”