Page 1 of 1

Code in UDT prevents template that contains the UDT saving

Posted: Fri Apr 19, 2013 6:48 am
by davids355
I have a UDT with some php code in it, the UDT saves without a problem, and the code displays on my webpage without a problem.

However, If I go to edit the template from where the UDT is called, it will not allow me to save any changes - there is no error, it just will not acknowledge that I have pressed save or update.

I have narrowed the problem code down to these two lines:

Code: Select all

    if (!file_exists($LOCAL_FILENAME)) {
        die("Script error: $LOCAL_FILENAME does not exist. Please create a blank file 

named $LOCAL_FILENAME.");
    }


    if (!is_writable($LOCAL_FILENAME)) {
        die("Script error: $LOCAL_FILENAME is not writable. Please set write permissions 

on $LOCAL_FILENAME.");
   
 }
I am running CMS version 1.11.4.
The code in the UDT is from a third party and intended to display adverts.

If any more info needed let me know, and also if I have posted in the wrong section left me know.

Re: Code in UDT prevents template that contains the UDT savi

Posted: Fri Apr 19, 2013 7:44 am
by Rolf
I would start with changing die into echo

Re: Code in UDT prevents template that contains the UDT savi

Posted: Fri Apr 19, 2013 7:50 am
by davids355
Rolf wrote:I would start with changing die into echo
That's what I done. Just wondered the reason. Also not sure if breaking the code is against terms of third party.

Re: Code in UDT prevents template that contains the UDT savi

Posted: Fri Apr 19, 2013 8:00 am
by velden
if $LOCAL_FILENAME refers to a relative path that may be the reason.

If possible use an absolute path, best with the use of cmsms properties like root_path (if exists).

Mind that in the admin area your (by default) working from <cmsmroot>/admin/index.php while the frontend works from <cmsmsroot>/index.php

Re: Code in UDT prevents template that contains the UDT savi

Posted: Fri Apr 19, 2013 8:05 am
by davids355
velden wrote:if $LOCAL_FILENAME refers to a relative path that may be the reason.

If possible use an absolute path, best with the use of cmsms properties like root_path (if exists).

Mind that in the admin area your (by default) working from <cmsmroot>/admin/index.php while the frontend works from <cmsmsroot>/index.php
I believe $Local_filename is just a filename, i don't think there is a path appended at all, but i will check.

Re: Code in UDT prevents template that contains the UDT savi

Posted: Fri Apr 19, 2013 9:45 am
by velden
davids355 wrote:
velden wrote:if $LOCAL_FILENAME refers to a relative path that may be the reason.

If possible use an absolute path, best with the use of cmsms properties like root_path (if exists).

Mind that in the admin area your (by default) working from <cmsmroot>/admin/index.php while the frontend works from <cmsmsroot>/index.php
I believe $Local_filename is just a filename, i don't think there is a path appended at all, but i will check.
Well, that sure is relative then, isn't it?

Re: Code in UDT prevents template that contains the UDT savi

Posted: Fri Apr 19, 2013 3:54 pm
by davids355
I take your point. I will investigate this first and then post back.
velden wrote:
davids355 wrote:
velden wrote:if $LOCAL_FILENAME refers to a relative path that may be the reason.

If possible use an absolute path, best with the use of cmsms properties like root_path (if exists).

Mind that in the admin area your (by default) working from <cmsmroot>/admin/index.php while the frontend works from <cmsmsroot>/index.php
I believe $Local_filename is just a filename, i don't think there is a path appended at all, but i will check.
Well, that sure is relative then, isn't it?