Post by commodorecrush » Thu Nov 17, 2011 3:16 am

Where and/or how can I edit the parent category link?

For example I want two main parent links at the top of my navigation to simply link to an external blog page and one to an external auction page store.

I can't find anywhere to enter the link address. I guess that goes for sub-categories too? Is there a way to do this? I don't need every single category to go to an internal page on my site.

Thanks!


Posts

Joined
Thu Nov 17, 2011 3:11 am

Post by inactiveaccount9912 » Thu Nov 17, 2011 3:36 am

Edit the header.tpl of your current theme and insert your links manualy.
This is the default code for categories:
<?php if ($categories) { ?>
<div id="menu">
<ul>
<?php foreach ($categories as $category) { ?>
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php if ($category['children']) { ?>
<div>
<?php for ($i = 0; $i < count($category['children']);) { ?>
<ul>
<?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($category['children'][$i])) { ?>
<li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php } ?>
</li>
<?php } ?>
</ul>
</div>
<?php } ?>
With your links , should look something like this:
<?php if ($categories) { ?>
<div id="menu">
<ul>
<?php foreach ($categories as $category) { ?>
<li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
<?php if ($category['children']) { ?>
<div>
<?php for ($i = 0; $i < count($category['children']);) { ?>
<ul>
<?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
<?php for (; $i < $j; $i++) { ?>
<?php if (isset($category['children'][$i])) { ?>
<li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
<?php } ?>
<?php } ?>
</ul>
<?php } ?>
</div>
<?php } ?>
</li>
<?php } ?>
<li> <a href="http://outside location">Blog</a></li>
<li> <a href="http://outside location">Another external link</a></li>

</ul>
</div>
<?php } ?>

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by commodorecrush » Thu Nov 17, 2011 3:53 am

Awesome. Worked like a charm. I'm a noob and having a hard time just finding where certain module are located to edit them manually to my liking. Thanks again!


Posts

Joined
Thu Nov 17, 2011 3:11 am

Post by colours » Tue Mar 13, 2012 7:52 pm

Is it possible to be adapted to other language? Thanks in advance!

Newbie

Posts

Joined
Sun Feb 19, 2012 9:10 pm

Post by inactiveaccount9912 » Tue Mar 13, 2012 8:19 pm

For other languages/multilanguage.

Edit the file catalog/controller/common/header.php
and after the line

Code: Select all

$this->data['text_checkout'] = $this->language->get('text_checkout');
introduce your links text like this:

Code: Select all

$this->data['text_onelink'] = $this->language->get('text_onelink');
$this->data['text_anotherlink'] = $this->language->get('text_anotherlink');
Now edit the catalog/language/*/common/header.php and for each link above add its text like this;
Insert it after the comment line:

Code: Select all

// Text
like this:

Code: Select all

$_['text_onelink']        = 'The link name';
$_['text_anotherlink']       = 'Another link name';
Now, in the header.tpl file mentioned few posts above , the added lines should look like:

Code: Select all

<li> <a href="http://outside location"><?php echo $text_onelink; ?></a></li>
<li> <a href="http://outside location"><?php echo $text_anotherlink; ?></a></li>

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by colours » Tue Mar 13, 2012 8:56 pm

This is it! Thanx for your time again! The problem solved.

Newbie

Posts

Joined
Sun Feb 19, 2012 9:10 pm

Post by mandamexico » Tue Sep 25, 2012 1:23 pm

I get duplicate links on my category header. Both english and spanish links with the other switching from the text_spanishlink and text_englishlink when switching languages. I followed all steps correctly above and am using 1.5.4.1

take a look here http://www.mandamexico.com

My Extensions

OpenCart Developer (OCD) Tools

Donate - If I ever helped you.


User avatar
Active Member

Posts

Joined
Mon Jun 29, 2009 10:14 am
Location - Los Angeles, CA

Post by inactiveaccount9912 » Wed Sep 26, 2012 2:32 am

You are not supposed to make 2 variable one for english and one for spanish, please review the code above. There should be only one variable text_link that takes its value from language , and in the language file you will have taxt_link = something in the english file and text_link = something else in the language file.

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by mandamexico » Thu Sep 27, 2012 4:20 am

in the header.tpl file there should only be one variable? please advise im not sure where to have only one whether it be the header.php or .tpl file because it breaks when i remove one variable from the php and tpl files.

your instructions are confusing because u wrote two examples. i thought each example represented a diff language which was what the original poster wanted. my site still looks messed up :(

this might not work for the new 1.5.4.1 structure because i tried it EXACTLY how you posted in the instructions above to no avail :-\ please help!

My Extensions

OpenCart Developer (OCD) Tools

Donate - If I ever helped you.


User avatar
Active Member

Posts

Joined
Mon Jun 29, 2009 10:14 am
Location - Los Angeles, CA

Post by mandamexico » Thu Sep 27, 2012 4:32 am

here is my common/header.php code

Code: Select all

		$this->data['text_account'] = $this->language->get('text_account');
    	$this->data['text_checkout'] = $this->language->get('text_checkout');
		$this->data['text_spanishlink'] = $this->language->get('text_spanishlink');
		$this->data['text_englishlink'] = $this->language->get('text_englishlink');
here is my common/header.tpl code

Code: Select all

          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
    <li><a href="http://mandamexico.com/silver-membership"><?php echo $text_spanishlink; ?></a></li>
    <li><a href="http://mandamexico.com/silver-membership"><?php echo $text_englishlink; ?></a></li>
  </ul>
</div>
<?php } ?>
<div id="notification"></div>
language file in spanish

Code: Select all

$_['text_account']        = 'Mi Cuenta';
$_['text_checkout']       = 'Realizar Pedido';
$_['text_spanishlink']    = 'Membresia de Plata';
?>
english language file

Code: Select all

$_['text_account']        = 'My Account';
$_['text_checkout']       = 'Checkout';
$_['text_englishlink']    = 'Silver Membership';
?>

My Extensions

OpenCart Developer (OCD) Tools

Donate - If I ever helped you.


User avatar
Active Member

Posts

Joined
Mon Jun 29, 2009 10:14 am
Location - Los Angeles, CA

Post by inactiveaccount9912 » Thu Sep 27, 2012 4:39 am

You dont seem to understand how the language part works.
you dont need to have in the header.php controller:

Code: Select all

$this->data['text_spanishlink'] = $this->language->get('text_spanishlink');
      $this->data['text_englishlink'] = $this->language->get('text_englishlink');
you need to have only:

Code: Select all

$this->data['text_link'] = $this->language->get('text_link');
then in the language english file:

Code: Select all

$_['text_link']    = 'Silver Membership';
and in the spanish langage file:

Code: Select all

$_['text_link']    = 'Membresia de Plata';
and finaly, in the tpl, have just 1 line:

Code: Select all

<li><a href="http://mandamexico.com/silver-membership"><?php echo $text_link; ?></a></li>

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by mandamexico » Thu Sep 27, 2012 4:05 pm

yes i didnt understand it. thanks now i do! your last explanation was perfect!! :)

My Extensions

OpenCart Developer (OCD) Tools

Donate - If I ever helped you.


User avatar
Active Member

Posts

Joined
Mon Jun 29, 2009 10:14 am
Location - Los Angeles, CA

Post by inactiveaccount9912 » Mon Oct 01, 2012 5:22 pm

Glad you solved it.

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by vallentin24 » Wed Oct 17, 2012 1:13 pm

multumesc

Active Member

Posts

Joined
Fri Feb 03, 2012 1:00 am

Post by davski13 » Mon Dec 09, 2013 6:39 pm

Managed to make it work EXCEPT that the sub menu text links are visible all the time and there is only a background visible on each sub menu link on rollover.

Newbie

Posts

Joined
Tue Sep 11, 2012 12:03 am

Post by inactiveaccount9912 » Mon Dec 09, 2013 8:33 pm

How exactly did you add the submenu links?

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by davski13 » Mon Dec 09, 2013 9:29 pm

Hi Florinsith,
Thanks for taking the time to answer. My code looks like the following (actual URLs replaced):

Code: Select all

<div class="links"><a href="<?php echo $home; ?>"><?php echo $text_home; ?></a><a href="<?php echo $wishlist; ?>" id="wishlist-total"><?php echo $text_wishlist; ?></a><a href="<?php echo $account; ?>"><?php echo $text_account; ?></a><a href="<?php echo $shopping_cart; ?>"><?php echo $text_shopping_cart; ?></a><a href="<?php echo $checkout; ?>"><?php echo $text_checkout; ?></a></div>
</div>
<?php if ($categories) { ?>
<div id="menu">
  <ul>
    <?php foreach ($categories as $category) { ?>
    <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a>
      <?php if ($category['children']) { ?>
      <div>
        <?php for ($i = 0; $i < count($category['children']);) { ?>
        <ul>
          <?php $j = $i + ceil(count($category['children']) / $category['column']); ?>
          <?php for (; $i < $j; $i++) { ?>
          <?php if (isset($category['children'][$i])) { ?>
          <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li>
          <?php } ?>
          <?php } ?>
        </ul>
        <?php } ?>
      </div>
      <?php } ?>
    </li>
    <?php } ?>
    <li> <a href="http://www.external_link.co.uk/">Main_1</a>
		<ul>
			<li><a href="/notebooks/notebooks-macs">Sub_1</a></li>
			<li><a href="/notebooks/notebooks-windows">Sub_2</a></li>
			<li><a href="/notebooks/notebooks-macs">Sub_3</a></li>
			<li><a href="/notebooks/notebooks-macs">Sub_4</a></li>
			<li><a href="/notebooks/notebooks-macs">Sub_5</a></li>

		</ul></li>
  </ul>
</div>

Newbie

Posts

Joined
Tue Sep 11, 2012 12:03 am

Post by inactiveaccount9912 » Mon Dec 09, 2013 9:53 pm

The sublist must be in a div:

Code: Select all

<li> <a href="http://www.external_link.co.uk/">Main_1</a>
      <div><ul>
         <li><a href="/notebooks/notebooks-macs">Sub_1</a></li>
         <li><a href="/notebooks/notebooks-windows">Sub_2</a></li>
         <li><a href="/notebooks/notebooks-macs">Sub_3</a></li>
         <li><a href="/notebooks/notebooks-macs">Sub_4</a></li>
         <li><a href="/notebooks/notebooks-macs">Sub_5</a></li>
 </ul></div></li>

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by davski13 » Mon Dec 09, 2013 10:14 pm

Many thanks. Cracked it!

Newbie

Posts

Joined
Tue Sep 11, 2012 12:03 am

Post by jolly_roger » Fri Nov 07, 2014 1:24 am

Thanks florinsith! It's working just fine!

Newbie

Posts

Joined
Fri Nov 07, 2014 1:20 am
Who is online

Users browsing this forum: No registered users and 88 guests