Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Изменение цвета пункта меню модуля "Информация"


Recommended Posts

Здравствуйте. Вот задался вопросом как сделать выделение заголовков определенных статей в модуле "Информация".

Изначально имеем вид модуля:

Изображение

Есть желание изменить цвет определенного заголовка статьи и привести его к такому виду:

Изображение

Сам вывод модуля в шаблоне реализован так

<ul>
<?php foreach ($informations as $information) { ?>
<li><a href="<?php echo str_replace('&', '&', $information['href']); ?>"><?php echo $information['title']; ?></a></li>
<?php } ?>
<li><a href="<?php echo str_replace('&', '&', $contact); ?>"><?php echo $text_contact; ?></a></li>
<li><a href="<?php echo str_replace('&', '&', $sitemap); ?>"><?php echo $text_sitemap; ?></a></li>
</ul>

Вот тут у меня и возник вопрос - как для определенного id статьи сделать вывод другим цветом?

Link to comment
Share on other sites


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

<li><a href="<?php echo str_replace('&', '&', $contact); ?>"><font color="#ff0000"><?php echo $text_contact; ?></font></a></li>
Изображение
Link to comment
Share on other sites

<li><a href="<?php echo str_replace('&', '&', $contact); ?>"><font color="#ff0000"><?php echo $text_contact; ?></font></a></li>
Изображение

Да, для статей "Наши контакты" и "Карта сайта" делается именно так. У меня возник вопрос по статье которая берется из массива, например статьи "Политика Безопасности"

<?php foreach ($informations as $information) { ?>
<li><a href="<?php echo str_replace('&', '&', $information['href']); ?>"><?php echo $information['title']; ?></a></li>
<?php } ?>
Edited by shoom
Link to comment
Share on other sites


смотрите ID нужных вам статей

открываете

catalog/controller/module/information.php

меняете

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'])
			);
		}
на

foreach ($this->model_catalog_information->getInformations() as $result) {
			
			if ($result['information_id'] == "ТУТ ID, СТАТЬИ, КОТОРУЮ ХОТИТЕ _ПОДКРАСИТЬ_") {
				$information_style_start = "<span style=\"color:#FF0000;\">";
				$information_style_end = "</span>";
			} else {
				$information_style_start = "";
				$information_style_end = "";
			}
			
			$this->data['informations'][] = array(
				'title' => $information_style_start . $result['title'] . $information_style_end,
				'href'  => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=information/information&information_id=' . $result['information_id'])
			);
		}
  • +1 1
Link to comment
Share on other sites

Можно сделать более гибкий вариант... в массив informations добавить идентификатор статьи.

В файле catalog/controller/module/information.php найти

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'])
	);
}
и изменить так

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

После этого во вьювере можно каждому элементу списка поцепить свой класс.

В файле catalog/view/theme/НАЗВАНИЕ_ТЕМЫ/template/module/information.tpl найти строку

<li><a href="<?php echo str_replace('&', '&', $information['href']); ?>"><?php echo $information['title']; ?></a></li>
и изменить так

<li class="info_<?php echo $information['id']; ?>"><a href="<?php echo str_replace('&', '&', $information['href']); ?>"><?php echo $information['title']; ?></a></li>

Теперь стилями можно изголяться как угодно...

Link to comment
Share on other sites

смотрите ID нужных вам статей

открываете

catalog/controller/module/information.php

....

Благодарю за помощь:) Выбрал Ваш вариант. Со стилями, как предложил Yesvik, не получилось, может не там прописывал, хотя его вариант тоже понравился.

Link to comment
Share on other sites


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.