two questions: text? and custom_404

Please post answers on the most frequently asked questions about CMSimple
Post Reply
sareide
Posts: 21
Joined: Sat Apr 07, 2012 1:26 pm

two questions: text? and custom_404

Post by sareide » Sat Apr 28, 2012 7:58 am

Hi all
I've found inside cmsimple source the possibilty to have a custom_404 in order to redirect 404 error to something.
I have used this piece of code without results:
<?php
function custom_404() {
header('Location: http://www.google.com');
}

Any suggestion?

I have found inside the website configuration text1, text2 text3. But how to use them?

thanks in advance
sareide

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: two questions: text? and custom_404

Post by Gert » Sat Apr 28, 2012 8:59 am

sareide wrote:I have found inside the website configuration text1, text2 text3. But how to use them?
However you want, the variables are in the langconfig files (deconfig.php, enconfig.php ... ).

For example in a multiligual template:

Code: Select all

<?php echo $txc['template']['text1']; ?>
The Code for your custom_404 maybe:

Code: Select all

function custom_404() {
header('Location: http://www.google.com'); 
} 
or someting like this (an internal hidden "Custom 404 page"):

Code: Select all

function custom_404() {
header('Location: ?Custom_404_page'); 
} 
Add it to your cms.php or functions.php (Or make a userfuncs.php in the folder ./cmsimple/ with this code, so it will not be overwritten by an update),

Gert
Gert Ebersbach | CMSimple | Templates - Plugins - Services

sareide
Posts: 21
Joined: Sat Apr 07, 2012 1:26 pm

Re: two questions: text? and custom_404

Post by sareide » Sun Apr 29, 2012 7:36 pm

Sorry.
I was not able to install plugin or to have a correct result.
I still continue ho have problems with a blank content.

Before installing the plugin manager I switched to one of base templates.
then I copied cms.php and cmsconfig.php (with its new 3 lines) and copied pluginmanager.

I success in disabling plugins but I realized that the content page was blank.

sareide

cmb
Posts: 14227
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: two questions: text? and custom_404

Post by cmb » Sun Apr 29, 2012 7:48 pm

Hi sareide,

a blank page usually indicates a "fatal" PHP error. To detect this, the XHdebug mode might be helpful. Probably it's best, if you give it a try: http://www.cmsimple-xh.com/wiki/doku.ph ... debug_mode

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

sareide
Posts: 21
Joined: Sat Apr 07, 2012 1:26 pm

Re: two questions: text? and custom_404

Post by sareide » Sun Apr 29, 2012 8:21 pm

Hi
thanks a lot for you suggestion. I realized that I was using a custom function inside cms.php. Now all is working.

But what about to usesfunctions.php. Is a standard file that, if present, could be loaded? It would be the right place.

sareide




// Code added for pdf_link
function pdflink(){global $f,$search,$file,$sn,$su,$tx;$t=amp().'pdf';if($f=='search')$t.=amp().'function=search'.amp().'search='.$search;else if($f=='file')$t.=amp().'file='.$file;else if($f!=''&&$f!='save')$t.=amp().$f;return '<a href="'.$sn.'?'.$su.$t.'">'.$tx['menu']['pdf'].'</a>';}
// Code added custom

cmb
Posts: 14227
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: two questions: text? and custom_404

Post by cmb » Sun Apr 29, 2012 8:52 pm

Hi sareide,
sareide wrote:But what about to usesfunctions.php. Is a standard file that, if present, could be loaded? It would be the right place.
That's exactly what cmsimple/userfuncs.php is meant for. It will be included, if it exists, but it will not be overwritten by any update of CMSimple_XH.

Regarding pdflink(): do you have a solution for downloading/viewing the current CMSimple page as PDF? Quite a while ago I've made some experiments with mPDF, which worked nicely out of the box, but I was in doubt, if it could handle some fancy CSS and exotic fonts. I'm quite sure such automatic PDF conversion has it's limitations. But anyway, this could be a nice Addon.

Christoph

PS: About the custom_404(): did you manage to get it working?
Christoph M. Becker – Plugins for CMSimple_XH

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: two questions: text? and custom_404

Post by Holger » Wed May 02, 2012 11:16 am

cmb wrote:Regarding pdflink(): do you have a solution for downloading/viewing the current CMSimple page as PDF?
Hi Christoph,

I've made a "simple_PDF" - Plugin (not only) for that purpose.
You can test it live here (PDF erzeugen).
I'll release it ASAP.

Holger

cmb
Posts: 14227
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: two questions: text? and custom_404

Post by cmb » Wed May 02, 2012 11:44 am

Hi Holger,
Holger wrote:I've made a "simple_PDF" - Plugin (not only) for that purpose.
You can test it live here (PDF erzeugen).
I'll release it ASAP.
Sounds good! :D

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

sareide
Posts: 21
Joined: Sat Apr 07, 2012 1:26 pm

Re: two questions: text? and custom_404

Post by sareide » Wed May 02, 2012 1:13 pm

Hi.
About custom_404: I managed to get it working. I created a userfunc.php file inside cmsimple.

About PDF: I used an old solution for CMSIMPLE. It seems to work well (without plugin). But Now I've got a new problem. My site is multilanguage, so pdf library has some ploblems handling é, à, etc.

I'm going to find a workaround. If you wish I could share my code.

sareide

cmb
Posts: 14227
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: two questions: text? and custom_404

Post by cmb » Wed May 02, 2012 6:08 pm

Hi sareide,
sareide wrote:But Now I've got a new problem. My site is multilanguage, so pdf library has some ploblems handling é, à, etc.
That might be related to the UTF-8 encoded content. Either this encoding has to be set for the library, or other fonts are required (perhaps both?).
sareide wrote:If you wish I could share my code.
That would be nice! Probably others are interested in automatic PDF creation too.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply