Post by seers » Fri Feb 08, 2019 9:30 pm

Hello.

I am running OC 3.0.2.0 and looking for a way to show category description only on the category first page and hide it on 1, 2, 3 pages and so on.

I have to edit the category.twig file, but I am not famililar with the syntax.

I have found some code in the forum but it is for the older versions of OC.

Thank you in advance.

Newbie

Posts

Joined
Fri Nov 23, 2018 6:17 pm

Post by boicute.14 » Thu Feb 14, 2019 12:00 pm

first, you must have page variable on controller.
find

Code: Select all

		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}
and add $data['page'] = $page after
find {% if description %} in category.twig and edit {% if description and (page == 1) %} to display description when page == 1

Opencart Developer|Thiết kế website|Thiết kế website tại Đồng Nai


Newbie

Posts

Joined
Sat Oct 22, 2016 2:08 pm

Post by danielmedia74 » Sun Apr 11, 2021 10:03 am

boicute.14 wrote:
Thu Feb 14, 2019 12:00 pm
first, you must have page variable on controller.
find

Code: Select all

		if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}
and add $data['page'] = $page after
find {% if description %} in category.twig and edit {% if description and (page == 1) %} to display description when page == 1
As for the controller file
Not realy sure if i did get it correctly.

Code: Select all


if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}

Like this?

Code: Select all

	if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
			$data['page'] = $page
		}
		

Newbie

Posts

Joined
Thu Apr 08, 2021 9:21 pm

Post by straightlight » Sun Apr 11, 2021 10:13 am

Whatever you do with that block of code:

Code: Select all

if (isset($this->request->get['page'])) {
			$page = $this->request->get['page'];
		} else {
			$page = 1;
		}
Ensure it shows like this first:

Code: Select all

if (isset($this->request->get['page'])) {
			$page = (int)$this->request->get['page'];
		} else {
			$page = 1;
		}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: JNeuhoff and 113 guests