Zen Cart Logo
Forums / General Questions / require php file to be loaded into define pages editor?

require php file to be loaded into define pages editor?

Views: 1,050

Results 1 to 8 of 8
5 May 2015, 9:03 PM
#1
southshorepizza avatar

southshorepizza

Zen Follower

Join Date:
Sep 2012
Posts:
253
Plugin Contributions:
0

require php file to be loaded into define pages editor?

Usually in php you can add pages to another page by

<?php
include('add_this page.php');
include('add_this page_also.php');
?>

I can't seem to get this to work.
Can someone point me in the right direction with making this zen-cart friendly.

Thank you

5 May 2015, 9:35 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: require php file to be loaded into define pages editor?

southshorepizza:

Usually in php you can add pages to another page by

<?php include('add_this page.php'); include('add_this page_also.php'); ?>
> 
> I can't seem to get this to work.
> Can someone point me in the right direction with making this zen-cart friendly.
> 
> Thank you

That's the proper format to try to load add_this page_also.php if it exists at the designated path which in this case is at the root of your server. If it is at the root of your store, need to prepend DIR_FS_CATALOG. Otherwise based on the lack of information provided about what is happening, expected, not happening, etc... Anything else would be a guess.

Also, if "require" the file to be loaded, then need to use the require command instead of include.
5 May 2015, 9:41 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: require php file to be loaded into define pages editor?

Also, now that the title of this thread has been rereviewed, don't quite see the connection between the message and the title... Really need more information about what is being attempted. This infoshould have been in the original post to obtain the best assistance. See the posting tips above the message box when posting to the forum.

5 May 2015, 9:51 PM
#4
southshorepizza avatar

southshorepizza

Zen Follower

Join Date:
Sep 2012
Posts:
253
Plugin Contributions:
0

Re: require php file to be loaded into define pages editor?

So far to test it I have written Hello, and then added that line. I can see hello but the rest is blank.

Lets say add_this_page.php just says "Welcome to my store."
add_this_page_also.php says "Please enjoy your visit."

Expected output would be:
Hello, Welcome to my store. Please enjoy your visit.

Instead I get:
Hello

The files are located in the admin directory for now so I changed the code to:
Hello

<?php include(DIR_FS_ADMIN . 'add_this page.php'); include(DIR_FS_ADMIN . 'add_this page_also.php'); ?>

I did try moving the files into the store front side and using DIR_FS_CATALOG as well with no success.

Thank you

Maybe in the title I should have left off the "editor" but yes using the define pages editor to code a page. I want to include other php pages to be included on that same page as part of the page.

5 May 2015, 10:02 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: require php file to be loaded into define pages editor?

Well, if your plan is to have these files "added" onthestore front side, they will need to be somewhere on the catalog side as the admin directory is not known from that side.

Further, I thought there were some restrictions about using php in this way on the define pages editor, but let's put that aside for the moment.

What happens if you begin the first file with ?> So that the content is pushed outside of a php code attempt. Btw, any error logs? Cache directory for ZC 1.5.0 and below or logs directory in 1.5.1 and above.

5 May 2015, 10:08 PM
#6
southshorepizza avatar

southshorepizza

Zen Follower

Join Date:
Sep 2012
Posts:
253
Plugin Contributions:
0

Re: require php file to be loaded into define pages editor?

Cannot redeclare zen_parse_url() (previously declared in /home/w57dsjmm/public_html/order/admin/includes/application_top.php:160) in /home/w57dsjmm/public_html/order/admin/includes/application_top.php on line 186
is the log file.

by removing the ?> from the define page and the <?php from the add_this page.php I still get the same error message.

5 May 2015, 10:16 PM
#7
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: require php file to be loaded into define pages editor?

By first file I meant the first included file (load_this page.php)... As to the error, interesting as it appears something is trying to load and redeclare a function/file already loaded...

5 May 2015, 10:38 PM
#8
southshorepizza avatar

southshorepizza

Zen Follower

Join Date:
Sep 2012
Posts:
253
Plugin Contributions:
0

Re: require php file to be loaded into define pages editor?

I got it to work. But I'm not sure what made it work. I cleared cache and it started working. :( Rookie mistake!!:frusty: