Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Display define_page_2,define_page_3,define_page_4 etc on homepage

Display define_page_2,define_page_3,define_page_4 etc on homepage

Views: 995

Results 1 to 11 of 11
13 Jul 2016, 5:54 PM
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Display define_page_2,define_page_3,define_page_4 etc on homepage

I have a set of tabs on my homepage that a user clicks through to see content from each tab.

How would I pull content from languages/html_includes/MYTEMPLATE/define_page_2.php, languages/html_includes/MYTEMPLATE/define_page_3.php, languages/html_includes/MYTEMPLATE/define_page_4.php into each tab?

14 Jul 2016, 10:56 AM
#2
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

Ok I didn't get a response to this. Here's another way of looking at it. Is it possible to display an EZ Pages content on another page such as the homepage?

15 Jul 2016, 5:49 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

Given that you want to suck in content from numerous other pages, all to be displayed on one common page, you may run into some styling and language-define challenges. But yes it's possible.

You can see in the module and template for each page how to pull in the requisite content.

The module file prepares the data for use by the template:
eg: /includes/modules/pages/page_2/header_php.php

$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false');

And the template displays it:
eg: /includes/templates/your_template/templates/tpl_page_2_default.php

  require($define_page);

Similar with ez-pages, although a lot more work is done in the module file, based on the selected page number in the URL:
eg: /includes/modules/pages/page/header_php.php

$ezpage_id = (int)$_GET['id']; // from &id=xxxx in the URL
$sql = "select * from " . TABLE_EZPAGES . " where pages_id = " . (int)$ezpage_id;
$var_pageDetails = $db->Execute($sql);

And the template displays it:
eg: /includes/templates/your_template/templates/tpl_page_default.php

  echo $var_pageDetails->fields['pages_html_text'];
18 Jul 2016, 6:50 PM
#4
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

Right I'd already tried your first option of placing

$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false');

in pages/index/header_php.php or

in templates/MYTEMPLATE/templates/index_categories.php or in in templates/MYTEMPLATE/templates/tpl_index_default.php

The end result is that any text that was defined in includes/languages/english/html_includes/MYTEMPLATE/define_main_page.php disappears and is replaced by define_page_2.php

Also if I then go on to do something like:

<?php $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false'); ?><br /> <?php $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_3, 'false'); ?><br /> <?php $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_4, 'false'); ?>

it will only display FILENAME_DEFINE_PAGE_4 instead of all three.

I didn't try the more complex EZ Pages option as I gathered using page_defines might be much easier.

18 Jul 2016, 9:48 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

Nick1973:

Right I'd already tried your first option of placing

$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false');

in pages/index/header_php.php or

in templates/MYTEMPLATE/templates/index_categories.php or in in templates/MYTEMPLATE/templates/tpl_index_default.php

The end result is that any text that was defined in includes/languages/english/html_includes/MYTEMPLATE/define_main_page.php disappears and is replaced by define_page_2.php

Also if I then go on to do something like:

<?php $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false'); ?><br /> <?php $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_3, 'false'); ?><br /> <?php $define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_4, 'false'); ?>

it will only display FILENAME_DEFINE_PAGE_4 instead of all three.
That's because there's two steps: the module, then the template, as I showed above:
a) $define_page = XYZ
b) require($define_page);

So if you want to output all three, set the variable, then require it. Then set the variable again, and require it, etc.

Or use different variable names, such as $define1, $define2, $define3, etc. And then in the template require($define1) and then require($define2) where you want it, etc etc

18 Jul 2016, 10:50 PM
#6
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

ok so where exactly would i put these lines of code as I tried in modules/pages/index/header_php.php and found the same thing happened.

19 Jul 2016, 12:36 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

header_php.php

$define2 = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false');
$define3 = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_3, 'false');
$define4 = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_4, 'false');

And then in your template file you simply insert a PHP require statement for whichever define-page you want to render in whatever particular location you want it to appear.

<div>..... your heading </div>
<div> some other stuff here </div>
<div class="example_tab_2"><?php require $define2; ?></div>
<div class="example_tab_3"><?php require $define3; ?></div>
<div class="example_tab_4"><?php require $define4; ?></div>
19 Jul 2016, 7:28 AM
#8
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

I take it

$define2 = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_2, 'false');
$define3 = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_3, 'false');
$define4 = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_PAGE_4, 'false');

goes into

modules/pages/index/header_php.php

would you put it somewhere around line 42/43 under

// include template specific file name defines
$define_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_MAIN_PAGE, 'false');
require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));

19 Jul 2016, 7:33 AM
#9
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

No need to answer that. It worked. Thanks for your answer.

Just out of interest how would I go about doing the same with EZ Pages, as this could be very useful with either solution.

19 Jul 2016, 1:59 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

If you look at my previous posts you can see where I described how to do it for both.
And then you asked me to write it all out exactly for the define-page approach.
You can follow the same pattern for ez-pages: in the module header file you create a variable into which you stuff the content. And then in the template you output its contents. In the case of ez-pages you'll notice that an echo is used instead of a require.

19 Jul 2016, 3:11 PM
#11
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Display define_page_2,define_page_3,define_page_4 etc on homepage

Yes thats fine and I think all understood. I've yet to try the EZ Pages method, but it all works well with page defines. You can view it working here http://www.imarque.com/paws on this website which is 'work in progress'. The text box in the center of the page is pulling content from define_page_1, 2 and 3 so you can flick through the text with each button at the top. And obviously the content could be anything like an image or s flash animation as well.