Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Clickable image on main page

Clickable image on main page

Views: 564

Results 1 to 6 of 6
13 Jul 2016, 12:24 PM
#1
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Clickable image on main page

I'm about ready to go live, and would like to put a clickable image on the main page to replace the static image I have there now. I know how to create a clickable image, and I think I've found the proper place to put the code, but I don't have a clue yet about how to wrap the code in a PHP command.

I think it needs to go in /includes/templates/template_default/templates/tpl_index_default.php around line 39. If anyone can help out with that, it would be very much appreciated.

13 Jul 2016, 3:21 PM
#2
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,771
Plugin Contributions:
9

Re: Clickable image on main page

Short on time. Just wanted to say that each new thread should be treated as if you are dealing with the hosting company's low level techy with the flow chart.
Every bit of information you give at the start gets to the solution much quicker. All those posting tips and WHICH image (in this case) prevents us having to search through posts for a link, go to the link, try to figure out WHICH static image, etc.

13 Jul 2016, 3:33 PM
#3
drbyte avatar

drbyte

Sensei

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

Re: Clickable image on main page

HeleneWallis:

/includes/templates/template_default/templates/tpl_index_default.php
Almost.
IF that were the file to change, then you would actually change THIS file:
/includes/templates/YOUR_TEMPLATE_FOLDERNAME_HERE/templates/tpl_index_default.php
... and if you don't already have that file, then COPY it from template_default, and edit the copy.

But, since you quoted line 39 that suggests that you're referring to code that's being output from the Define Page. And you can edit Define Pages in Admin->Tools->Define Pages Editor.
Then simply provide the requisite HTML to make the image clickable (you said you already know how to do that).

13 Jul 2016, 3:37 PM
#4
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Clickable image on main page

Thanks, I'll have a look at the define pages. Should have thought of that. I'd forgotten that the main page can be accessed through the admin panel.

13 Jul 2016, 3:43 PM
#5
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Clickable image on main page

First of all, to save yourself on future upgrades, the file changes should not be made to files in the template_default directory but instead the file should be copied to your template's directory and then modified from there.

As to adding the click portion to the image, you'll be adding an <a tag before the declaration/echo of the image and a closing </a> tag at an html validation point after the image. Here is the code around line 39 of the referenced file starting at line 28:

<!-- deprecated - to use uncomment this section
<?php if (TEXT_INFORMATION) { ?>
<div id="" class="content"><?php echo TEXT_INFORMATION; ?></div>
<?php } ?>-->

<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?>
<?php
/**
 * get the Define Main Page Text
 */
?>
<div id="indexDefaultMainContent" class="content"><?php require($define_page); ?></div>
<?php } ?>

With this being line 39:

<div id="indexDefaultMainContent" class="content"><?php require($define_page); ?></div>

So if you wanted an image to appear before this content (so that it at the top) then you could add the following just before than line/moving that line down:

<a href="<?php echo zen_href_link('main_page_name', 'parameters', $request_type); ?>" ><?php echo zen_image('path_to_image', 'alt_text', 'image_width_if_desired', 'image_height_if_desired', 'parameters_if_desired'); ?>

This would provide a little dynamic capability to the site such that if the code and files of this site are moved elsewhere, then the links and images should still function normally.

14 Jul 2016, 1:22 AM
#6
helenewallis avatar

helenewallis

Totally Zenned

Join Date:
Jun 2016
Location:
Suffolk VA
Posts:
625
Plugin Contributions:
0

Re: Clickable image on main page

Thanks very much! I realized after posting that this should be done in my own template directory. But it looks like using the Define Pages Editor will work just fine for this particular application. The code tutorial helps anyway. I'll eventually get my head wrapped around PHP. Just don't have time right now.