Page 1 of 1

Preview exceptions [solved]

Posted: Wed Oct 21, 2009 7:22 pm
by chiggeybean
In 1.5, I used the following code to avoid a bug that caused the preview to crap out.

Code: Select all

{if $SCRIPT_NAME != "/preview.php"}
       {sectiontitle levels='2'}
{/if}
This would allow my tag to render results in a browser, nothing in preview.

Now in 1.6.6, the preview mechanism has apparently changed and the above no longer works. I noticed the page is now editcontent.php, but replacing preview.php with editcontent.php doesn't seem to work either.

Anyone have an idea how to do this?

Re: Preview exceptions

Posted: Fri Jun 11, 2010 10:09 pm
by chiggeybean
Still a problem - thought I'd bump this to see if anyone had an idea. Now on 1.7.1

Re: Preview exceptions

Posted: Sat Jun 12, 2010 9:02 am
by NaN
What bug do you mean?
And why should the {sectiontitle ... } only be shown if not in preview?
Where do you put these lines?

If i print out {$SCRIPT_NAME} in a page content i see "index.php". Even if viewing the page in preview tab.
No preview.php nor editcontent.php.

The only thing to check if you're in preview is to check for the page that is showed.
If it is "__CMS_PREVIEW_PAGE__" you're in preview.

E.g. if in your config.php $config['query_string'] is set to "page" the url to the preview page is

yourDomain/index.php?page=__CMS_PREVIEW_PAGE__

So if you want things not to be processed in preview i would do it that way:

{if $smarty.get.page != '__CMS_PREVIEW_PAGE__'}
...
{/if}

I don't know if this is what you're looking for.

Re: Preview exceptions

Posted: Sun Jun 13, 2010 3:24 pm
by chiggeybean
Thanks NaN! That worked perfectly.

The reason I do this is that {sectiontitle} causes preview to not render. By leaving this one little thing out of the preview, it works fine.