Output of information links in the header of the site opencart
Add the ability to output links to the header of the online store opencart
Creation, development, manufacturing sites | WEB-STYDIA.COM

Guys how often you had situations when you needed to display a link to an information article in the right place on your site similarly to those that you display in the basement of the site, for example you need to add a link to the page in the menu or anywhere else in the header of the online store! ?
The first thing that comes to mind is to write down the link you need straight in the store template, But I think this approach is not entirely correct, and there are several reasons for this.

Let's say you have a site in different languages then you can not just specify the name of the link that would be displayed correctly in different languages, or you have changed the address of the link, and you have to constantly climb into the template and change this link, well, there are other disadvantages of this solutions.

On this here you decide which method is more acceptable for you, but today I want to tell you how to bring a link to the header of an online store or menu similarly to what you display in the basement with the ability to turn on and off the necessary information page.

As it looks you can clearly see in the screenshot below:

Well, let's start our task and add the ability to display information links added to the admin panel of the opencart store in the header or menu.

First of all, let's add the option in the admin panel to enable or disable the display of the link to the desired article.



1. Open the file admin/view/template/catalog/information_form.tpl

We find a piece of code:

And after it we add:

2. Open the file admin/controller/catalog/information.php

We are looking for a line:

After which we add:

Further we find the code:

After which we add the following:

3. Open the language file admin/language/russian/catalog/information.php

We find a row:

After which we add:

The same is done with other language files.

4. Open the file admin/model/catalog/information.php

Find the string:

And replace it with:

This line occurs twice and both times we make a replacement.

5. We go to the database of our store using phpmyadmin or any other method that you use to manage the database tables:

Look for the table:

And in this table we add a new field after the bottom field in which we will write the value of the inclusion or deactivation of the output of the link:

All of the settings in the admin panel have finished, and now you have a new chebox that you enable or disable in the article, now proceed directly to the link output itself in the template header or template menu.



1. Open the file: catalog/controller/common/header.php

We find in it a row with the code:

And before this line, add the following code:

2. Open the file catalog/view/theme/default/template/common/header.tpl

In it we search for the output of the menu and where at the end of the output of the menu:
Adding:

So in the end you have something like this:

That's basically all, now you can turn on or off the necessary articles from the admin panel and display them in the site menu.

Yes, and even if you want to display them not in the menu but for example at the very top of the site header, where you have the links to log in, register, main, etc. ...

Then the last item is done a bit differently, that is, we look for the line:

And add to it:

What would have happened in the end:

Well, in general, that's all!

Now you do not need to constantly change something, you just include the output of the desired article in the header of your online store, just like you did with the output of the links in the basement.

Test and comment, good luck.

You may also like

No Comment

You can post first response comment.

Leave A Comment

Please enter your name. Please enter an valid email address. Please enter a message.