Jump to content
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

Как сменить цвет одной категории?


Recommended Posts

В модуле категории все пункты пишутся одним цветом. Как сменить цвет только одного пунки (например последнего)?

Подскажите пожалуйси, никак не могу разобраться

Link to comment
Share on other sites


  • 4 months later...

у каждой категории есть уникальный id, который ей присваивается при создании.

при вывогде категорий посивь условие, если найгден нужный id, то выводить другим цветом.

Link to comment
Share on other sites


в файле controller/module/category.php находите (примерно 55 строка)

if ($this->category_id == $result['category_id']) {
				
				$output .= ' class="active"><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '"><b>' . $result['name'] . '</b></a>';
и приводите к виду

if ($this->category_id == $result['category_id']) {
				
				$output .= ' class="active"><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '"><b>' . $result['name'] . '</b></a>';
			} elseif ($result['category_id'] == 45) {
				
				$output .= ' id="need"><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '">' . $result['name'] . '</a>';
			} else {
				
				$output .= '><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '">' . $result['name'] . '</a>';
			}
			

        	$output .= $children;
        
        	$output .= '</li>';

ггде 45 - id необходимой категории.

дальше в stylesheet.css пишете уже что нужно

#need {
     font-color: red; 
}
Link to comment
Share on other sites


Всё рилииет. Ты нужный id категории посивил? Или скопипастил привегденный код как есть?

Link to comment
Share on other sites


Всё рилииет. Ты нужный id категории посивил? Или скопипастил привегденный код как есть?

Сивил нужный. Что это за класс class="active"? Изначально в когде икого нет.
Link to comment
Share on other sites


Я же правильно понял что в id категории писать 5, если всего 5 категорий и выгделить нужно последнюю?

Пропотому чтовал гделать ик

if ($this->category_id == $result['category_id']) {
                                
                                $output .= '<a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '"><b>' . $result['name'] . '</b></a>';
                        } elseif ($result['name'] == Desktops) {
                                
                                $output .= '<a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '" id="need">' . $result['name'] . '</a>';
                        } else {
                                
                                $output .= '<a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '">' . $result['name'] . '</a>';
                        }
                        

                $output .= $children;
        
                $output .= '</li>'; 

Да рилииет, но только с английскими названиями категорий

Link to comment
Share on other sites


Я же правильно понял что в id категории писать 5, если всего 5 категорий и выгделить нужно последнюю?

нет, id нужной категории можно посмотреть в админке, нажав на "Изменить".

class="active" присваивается активной на данный момент категории (как правило выгделяется полужирным шрифтом).

Link to comment
Share on other sites


  • 2 months later...
  • 1 year later...

в файле controller/module/category.php находите (примерно 55 строка)

if ($this->category_id == $result['category_id']) {

			$output .= ' class="active"><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '"><b>' . $result['name'] . '</b></a>';

и приводите к виду

if ($this->category_id == $result['category_id']) {

			$output .= ' class="active"><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '"><b>' . $result['name'] . '</b></a>';
		} elseif ($result['category_id'] == 45) {

			$output .= ' id="need"><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '">' . $result['name'] . '</a>';
		} else {

			$output .= '><a href="' . $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $new_path)  . '">' . $result['name'] . '</a>';
		}


		$output .= $children;

		$output .= '</li>'; 

ггде 45 - id необходимой категории.

дальше в stylesheet.css пишете уже что нужно

#need {
 font-color: red;
}

Нету иких строк!!!

В новой версии "в файле controller/module/category.php находите (примерно 55 строка)

if ($this->category_id == $result['category_id']) {

$output .= ' class="active"><a href="'" нету иких строчек.

Суть вопроса: есть категории в верхнем меню. 2 последнии категории "Новинки" и "Акции". Хотелось бы поменять цвет этих двух категорий или хотя бы одной, а в игдено может кто знает, возможно ли згделать текст динамически переливающимся????

Заранее благодарен.

Link to comment
Share on other sites


  • 5 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.