Post by iain_darkflare » Wed Dec 09, 2009 12:50 am

Hi everyone,

Apologies if this has come up in another thread, but I have tried search several times with no luck.


I'm new to OpenCart, and having my first attempt at creating a template.

The main issue that I have discovered so far is to do with the information pages. When on the "Terms & Conditions" page for example, the navigation link to that page remains in it's normal state.

However on all product or category pages, a <b> is wrapped around the active/current page's link. Therefore it is very easy to edit the css and set the navigation link to a different style for the current page.

It seems that this is not set up for any of the information pages that are created.

I have identified the code that does this for the categories within controller/module/category.php

Code: Select all

if ($this->category_id == $result['category_id']) {
$output .= '<a href="' . $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $new_path))  . '"><b>' . $result['name'] . '</b></a>';
} else {
$output .= '<a href="' . $this->model_tool_seo_url->rewrite($this->url->http('product/category&path=' . $new_path))  . '">' . $result['name'] . '</a>';
			}
I have had a look at controller/module/information.php for a similar section, but there is nothing obvious that I can edit to achieve an active page state.

Does anyone know how to edit the information navigation links so the active page link is different from the rest?

Any help would be much appreciated.

Iain.

Dark Flare Design :: http://www.darkflaredesign.co.uk :: Web, Print and Logo Design, Ayr


User avatar

Posts

Joined
Wed Dec 09, 2009 12:39 am
Location - Ayr, Scotland

Post by Xsecrets » Thu Dec 10, 2009 12:49 am

This will get the information pages to bold, however it does not take into account the contact or sitemap.

in catalog/controler/module/information.php

change

Code: Select all

foreach ($this->model_catalog_information->getInformations() as $result) {
      		$this->data['informations'][] = array(
        		'title' => $result['title'],
	    		'href'  => $this->model_tool_seo_url->rewrite($this->url->http('information/information&information_id=' . $result['information_id']))
      		);
    	}
to

Code: Select all

foreach ($this->model_catalog_information->getInformations() as $result) {
      		$this->data['informations'][] = array(
        		'title' => $result['title'],
			'information_id' => $result['information_id'],
	    		'href'  => $this->model_tool_seo_url->rewrite($this->url->http('information/information&information_id=' . $result['information_id']))
      		);
    	}
then in catalog/view/theme/{yourtemplate}/template/module/information.tpl
change

Code: Select all

      <?php foreach ($informations as $information) { ?>
      <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
      <?php } ?>
to

Code: Select all

      <?php foreach ($informations as $information) { ?>
      <?php if(isset($_GET['information_id']) && $information['information_id'] == $_GET['information_id']){ ?>
      <li><b><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></b></li>  
      <?php }else{ ?>
      <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
      <?php } ?>
      <?php } ?>
Last edited by Xsecrets on Thu Dec 10, 2009 1:03 am, edited 1 time in total.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Newbie

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by iain_darkflare » Thu Dec 10, 2009 1:02 am

Thanks v.much for the reply.

I have made the changes you suggested, and I am nowgetting this error:
Notice: Undefined index: information_id in C:\xampp\htdocs\tiama\catalog\view\theme\tiama\template\module\information.tpl on line 4
Any idea where/how I go about defining 'information_id'?

Dark Flare Design :: http://www.darkflaredesign.co.uk :: Web, Print and Logo Design, Ayr


User avatar

Posts

Joined
Wed Dec 09, 2009 12:39 am
Location - Ayr, Scotland

Post by Xsecrets » Thu Dec 10, 2009 1:04 am

iain_darkflare wrote:Thanks v.much for the reply.

I have made the changes you suggested, and I am nowgetting this error:
Notice: Undefined index: information_id in C:\xampp\htdocs\tiama\catalog\view\theme\tiama\template\module\information.tpl on line 4
Any idea where/how I go about defining 'information_id'?
Redo it sorry I had an error in there. I just got through editing the post with the update.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Newbie

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by iain_darkflare » Thu Dec 10, 2009 1:27 am

Thats great thanks very much! I just couldn't get my head around it.

I didn't realise that the contact link is generated separately within the same module, do you know how to achieve the same effect on that?

Is it as simple as this:

Code: Select all

<?php if(isset($_GET['information_id']) && $information['information_id'] == $_GET['information_id']){ ?>
	<li><b><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></b></li>
    <?php }else{ ?>
	<li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
    <?php } ?>

Dark Flare Design :: http://www.darkflaredesign.co.uk :: Web, Print and Logo Design, Ayr


User avatar

Posts

Joined
Wed Dec 09, 2009 12:39 am
Location - Ayr, Scotland

Post by Xsecrets » Thu Dec 10, 2009 1:56 am

iain_darkflare wrote:Thats great thanks very much! I just couldn't get my head around it.

I didn't realise that the contact link is generated separately within the same module, do you know how to achieve the same effect on that?

Is it as simple as this:

Code: Select all

<?php if(isset($_GET['information_id']) && $information['information_id'] == $_GET['information_id']){ ?>
	<li><b><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></b></li>
    <?php }else{ ?>
	<li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
    <?php } ?>
no because the contact and sitemap are not actually information pages.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Newbie

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Xsecrets » Thu Dec 10, 2009 2:10 am

ok change the the code for the contact and sitemap links in information.tpl with

Code: Select all

      <?php if ($this->request->get['route'] == 'information/contact') { ?>
      <li><b><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></b></li>
      <?php }else{ ?>
      <li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>  
      <?php } ?>
      <?php if ($this->request->get['route'] == 'information/sitemap') { ?>
      <li><b><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></b></li>
      <?php }else{ ?>
      <li><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>
      <?php } ?>

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Newbie

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by iain_darkflare » Thu Dec 10, 2009 2:32 am

Worked a charm.

Thanks, it is very much appreciated.

Dark Flare Design :: http://www.darkflaredesign.co.uk :: Web, Print and Logo Design, Ayr


User avatar

Posts

Joined
Wed Dec 09, 2009 12:39 am
Location - Ayr, Scotland

Post by iain_darkflare » Mon Feb 01, 2010 10:41 pm

Apologies for opening up an old post, but the project got shelved for a couple of months, as it is for my sister.

I've just started back on the site, and I have noticed that when accessing the site via the direct link I get this error in the menu, between the Terms... & Contact links/buttons.

"Notice: Undefined index: route in C:\xampp\htdocs\tiama\catalog\view\theme\tiama\template\module\information.tpl on line 10"

This however does not appear if you go back to the home page via any of the links or menus.

Does anyone know how to define "route"?

Here is the code within information.tpl

Code: Select all

<h4><?php echo $heading_title; ?></h4>
<ul>
    <?php foreach ($informations as $information) { ?>
    <?php if(isset($_GET['information_id']) && $information['information_id'] == $_GET['information_id']){ ?>
    <li><a href="<?php echo $information['href']; ?>"><b><?php echo $information['title']; ?></b></a></li> 
    <?php }else{ ?>
    <li><a href="<?php echo $information['href']; ?>"><?php echo $information['title']; ?></a></li>
    <?php } ?>
    <?php } ?>
    <?php if ($this->request->get['route'] == 'information/contact') { ?>
    <li><a href="<?php echo $contact; ?>"><b><?php echo $text_contact; ?></b></a></li>
    <?php }else{ ?>
    <li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li> 
    <?php } ?>
</ul>
Any help would be much appreciated.

Dark Flare Design :: http://www.darkflaredesign.co.uk :: Web, Print and Logo Design, Ayr


User avatar

Posts

Joined
Wed Dec 09, 2009 12:39 am
Location - Ayr, Scotland

Post by iain_darkflare » Wed Feb 17, 2010 2:06 am

Any ideas? I'm totally stuck on this one :(

Dark Flare Design :: http://www.darkflaredesign.co.uk :: Web, Print and Logo Design, Ayr


User avatar

Posts

Joined
Wed Dec 09, 2009 12:39 am
Location - Ayr, Scotland

Post by jamesw » Mon Jul 19, 2010 10:28 am

Hi,

I know this is an old post, but I had the same problem as iain_darkflare, with route being undefined on the homepage.

I tried defining the route, but I'm new at opencart and still getting my head around how everything works, and really couldn't figure it out.

So instead of defining the route, I just used an if empty statement to start it off, and that way on the homepage (where route is undefined) it will use the empty statement first, so you don't get the nasty undefined error.

In my example I used class="currentpagehighlight" (and then defined the highlight properties in css) rather than <b> tags.

Code: Select all

      

<?php if (empty($this->request->get['route'])) { ?>
      <li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
      <?php } else if ($this->request->get['route'] == 'information/contact') { ?>
      <li class="currentpagehighlight"><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li>
      <?php }else{ ?>
      <li><a href="<?php echo $contact; ?>"><?php echo $text_contact; ?></a></li> 
      <?php } ?>

Code: Select all

   

<?php if (empty($this->request->get['route'])) { ?>
      <li class="currentpagehighlight"><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>
      <?php } else if ($this->request->get['route'] == 'information/sitemap') { ?>
      <li class="currentpagehighlight"><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>
      <?php }else{ ?>
      <li><a href="<?php echo $sitemap; ?>"><?php echo $text_sitemap; ?></a></li>
      <?php } ?>


Newbie

Posts

Joined
Mon Jul 19, 2010 10:16 am

Post by fido-x » Mon Jul 19, 2010 11:39 am

Yuck! Since you have to edit the controller to make any of this work, it seems more logical to do most of the work in the controller rather than in the template.

In "catalog/controller/module/information.php", replace the following:-

Code: Select all

foreach ($this->model_catalog_information->getInformations() as $result) {
    $this->data['informations'][] = array(
        'title' => $result['title'],
        'href'  => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=information/information&information_id=' . $result['information_id']),
        'class' => $class
    );
} 
with:

Code: Select all

foreach ($this->model_catalog_information->getInformations() as $result) {
    if (isset($this->request->get['information_id'])) {
        if ($this->request->get['information_id'] == $result['information_id']) {
            $class = 'active';
        } else {
            $class = 'inactive';
        }
    } else {
        $class = 'inactive';
    }
    $this->data['informations'][] = array(
        'title' => $result['title'],
        'href'  => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=information/information&information_id=' . $result['information_id']),
        'class' => $class
    );
} 
Then add the following:-

Code: Select all

if (isset($this->request->get['route'])) {
    if ($this->request->get['route'] == 'information/contact') {
        $this->data['contact_class'] = 'active';
    } else {
        $this->data['contact_class'] = 'inactive';
    }
    if ($this->request->get['route'] == 'information/sitemap') {
        $this->data['sitemap_class'] = 'active';
    } else {
        $this->data['sitemap_class'] = 'inactive';
    }
} else {
    $this->data['contact_class'] = 'inactive';
    $this->data['sitemap_class'] = 'inactive';
} 
Replace the contents of "catalog/view/theme/default/template/module/information.tpl" with:

Code: Select all

<div class="box">
  <div class="top"><img src="catalog/view/theme/<?php echo $template; ?>/image/information.png" alt="" /><?php echo $heading_title; ?></div>
  <div id="information" class="middle">
    <ul>
      <?php foreach ($informations as $information) { ?>
      <li><a class="<?php echo $information['class']; ?>" href="<?php echo str_replace('&', '&', $information['href']); ?>"><?php echo $information['title']; ?></a></li>
      <?php } ?>
      <li><a class="<?php echo $contact_class; ?>" href="<?php echo str_replace('&', '&', $contact); ?>"><?php echo $text_contact; ?></a></li>
      <li><a class="<?php echo $sitemap_class; ?>" href="<?php echo str_replace('&', '&', $sitemap); ?>"><?php echo $text_sitemap; ?></a></li>
    </ul>
  </div>
  <div class="bottom">&nbsp;</div>
</div>
Add a bit of style for it in your stylesheet (catalog/view/theme/default/stylesheet/stylesheet.css), like so:

Code: Select all

#information a, #information a.inactive {
    font-weight: normal;
}
#information a.active {
    font-weight: bold;
} 

Image
Modules for OpenCart 2.3.0.2
Homepage Module [Free - since OpenCart 0.7.7]
Multistore Extensions
Store Manager Multi-Vendor/Multi-Store management tool

If you're not living on the edge ... you're taking up too much space!


User avatar
Newbie

Posts

Joined
Sat Jun 28, 2008 1:09 am
Location - Tasmania, Australia

Post by outoftheordinary » Tue Feb 05, 2013 12:08 pm

Hi fido-x,

How can I apply this in version 1.5.3.1? There are some changes in information.php 1.5.3.1. Sorry I'm not really expert in PHP :choke:

outoftheordinary



Posts

Joined
Sun Nov 18, 2012 11:28 am

Post by outoftheordinary » Sun Feb 10, 2013 12:54 am

Guys, does anyone know how to accomplish this in default 1.5.3.1? All I want is the information links excluding contact & sitemap. I tried to apply this style structure in to 1.5.3.1 but no luck :(

1.5.3.1

Code: Select all

foreach ($this->model_catalog_information->getInformations() as $result) {
fido-x

Code: Select all

if (isset($this->request->get['information_id'])) {
        if ($this->request->get['information_id'] == $result['information_id']) {
            $class = 'active';
        } else {
            $class = 'inactive';
        }
    } else {
        $class = 'inactive';
    }
1.5.3.1

Code: Select all

$this->data['informations'][] = array(
        		'title' => $result['title'],
	    		'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
      		);
    	}
Results

Code: Select all

foreach ($this->model_catalog_information->getInformations() as $result) {
      		
		if (isset($this->request->get['information_id'])) {
		        if ($this->request->get['information_id'] == $result['information_id']) {
		            $class = 'active';
		        } else {
		            $class = 'inactive';
		        }
		    } else {
		        $class = 'inactive';
		    }

      		$this->data['informations'][] = array(
        		'title' => $result['title'],
	    		'href'  => $this->url->link('information/information', 'information_id=' . $result['information_id'])
      		);
    	}

outoftheordinary



Posts

Joined
Sun Nov 18, 2012 11:28 am

Post by domtechnolabs » Wed Jan 04, 2017 8:26 pm

Everything is working great. but i activate seo friendly url, its not working. any suggestion?

Newbie

Posts

Joined
Wed Jan 04, 2017 8:23 pm
Who is online

Users browsing this forum: No registered users and 27 guests