Перейти к публикации
Поиск в
  • Дополнительно...
Искать результаты, содержащие...
Искать результаты в...

Вывод скрипта на одной информационной странице


dofus
 Поделиться

Рекомендованные сообщения

Привет друзья!
Есть необходимость вывести скрипт на информационной странице с Доставкой
Реализовано было все путем добавления в файл information.tpl следующего

<? if ($_SERVER['REQUEST_URI']=="/delivery") {
//здесь ваш код
}
?>

Но скрипт появился на всех информационных страницах
Пример:

https://amalora.ru/delivery

https://amalora.ru/about_us

 

Подскажите, где ошибка?

Ссылка на комментарий
Поделиться на других сайтах


Добавить скрипт в текстовом редакторе в описании самой статьи в режиме исходного кода...

Ссылка на комментарий
Поделиться на других сайтах

20.03.2022 в 20:27, dofus сказал:

Привет друзья!
Есть необходимость вывести скрипт на информационной странице с Доставкой
Реализовано было все путем добавления в файл information.tpl следующего

<? if ($_SERVER['REQUEST_URI']=="/delivery") {
//здесь ваш код
}
?>

Но скрипт появился на всех информационных страницах
Пример:

https://amalora.ru/delivery

https://amalora.ru/about_us

 

Подскажите, где ошибка?

напишите echo $_SERVER['REQUEST_URI'];

и посмотрите что выводится и сравните с вашим условием...

Ссылка на комментарий
Поделиться на других сайтах


20.03.2022 в 21:45, Tom сказал:

Добавить скрипт в текстовом редакторе в описании самой статьи в режиме исходного кода...

Был бы рад, если было бы так просто

НО

Код вставленный через редактор не работает

<meta charset=" utf-8" =""="">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
	<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/font-awesome/3.1.0/css/font-awesome.min.css">
	
	

		<div class="page">
	
			
			<!-- tabs -->
			<div class="pcss3t pcss3t-effect-scale pcss3t-theme-1">
				<input type="radio" name="pcss3t" checked="" id="tab1" class="tab-content-first">
                <label for="tab1"><img src="https://amalora.ru/sdek.jpg" style="width: 100px;"></label>
				
				<input type="radio" name="pcss3t" id="tab2" class="tab-content-2">
				<label for="tab2"><img src="https://amalora.ru/bb.jpg" style="width: 100px;"></label>
				
				<input type="radio" name="pcss3t" id="tab3" class="tab-content-3">
				<label for="tab3"><img src="https://amalora.ru/or.jpg" style="width: 100px;"></label>
				
				<input type="radio" name="pcss3t" id="tab5" class="tab-content-last">
				<label for="tab5"><img src="https://amalora.ru/pr.jpg" style="width: 100px;"></label>
				
				<ul>
					<li class="tab-content tab-content-first typography">
						<h1>Nikola Tesla</h1>
						<p>
						
						</p>
						</li>
					
					<li class="tab-content tab-content-2 typography" style="height: 740px;">
						<p>Стоимость доставки расчитывается для заказа стоимостью 2500 рублей и весом 1 кг. </br> Точную стоимость доставки Вы можете узнать при оформлении заказа</p>
						<p>
						<div id="boxberry_map"></div>
<script>
boxberry.openOnPage('boxberry_map');
boxberry.open(callback_function, '1$Yi5bHpD1-g8mdc5UubTuyYKLyDkIck3D','Москва','77737', 2000, 1000,
0, 27, 17, 5);

//Описать функцию callback_function, например:

function callback_function(result){
document.getElementById('city').innerHTML = result.name;
document.getElementById('js-pricedelivery').innerHTML = result.price;
document.getElementById('code_pvz').innerHTML = result.id;

result.name = encodeURIComponent(result.name) // Что бы избежать проблемы с кириллическими символами, на страницах отличными от UTF8, вы можете использовать функцию encodeURIComponent()

document.getElementById('name').innerHTML = result.name;
document.getElementById('address').innerHTML = result.address;
document.getElementById('workschedule').innerHTML = result.workschedule;
document.getElementById('phone').innerHTML = result.phone;
document.getElementById('period').innerHTML = result.period;
if (result.prepaid=='1') {
alert('Отделение работает только по предоплате!');
}
}
</script></p>
						</li>
					
					<li class="tab-content tab-content-3 typography">
						<h1>Albert Einstein</h1>
						<p>German-born theoretical physicist who developed the general theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). While best known for his mass–energy equivalence formula E = mc2 (which has been dubbed "the world's most famous equation"), he received the 1921 Nobel Prize in Physics "for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect". The latter was pivotal in establishing quantum theory.</p>
						<p>Near the beginning of his career, Einstein thought that Newtonian mechanics was no longer enough to reconcile the laws of classical mechanics with the laws of the electromagnetic field. This led to the development of his special theory of relativity. He realized, however, that the principle of relativity could also be extended to gravitational fields, and with his subsequent theory of gravitation in 1916, he published a paper on the general theory of relativity.</p>
						<p class="text-right"><em>Find out more about Albert Einstein from <a href="http://en.wikipedia.org/wiki/Albert_Einstein" target="_blank">Wikipedia</a>.</em></p>				
					</li>
					
					<li class="tab-content tab-content-last typography">
						<div class="typography">
							<h1>Isaac Newton</h1>
							<p>English physicist and mathematician who is widely regarded as one of the most influential scientists of all time and as a key figure in the scientific revolution. His book Philosophiæ Naturalis Principia Mathematica ("Mathematical Principles of Natural Philosophy"), first published in 1687, laid the foundations for most of classical mechanics. Newton also made seminal contributions to optics and shares credit with Gottfried Leibniz for the invention of the infinitesimal calculus.</p>
							<p>Newton's Principia formulated the laws of motion and universal gravitation that dominated scientists' view of the physical universe for the next three centuries. It also demonstrated that the motion of objects on the Earth and that of celestial bodies could be described by the same principles. By deriving Kepler's laws of planetary motion from his mathematical description of gravity, Newton removed the last doubts about the validity of the heliocentric model of the cosmos.</p>
						<p class="text-right"><em>Find out more about Isaac Newton from <a href="http://en.wikipedia.org/wiki/Isaac_Newton" target="_blank">Wikipedia</a>.</em></p>		
						</div>
					</li>
				</ul>
			</div>
			<!--/ tabs -->
		</div>

 

Ссылка на комментарий
Поделиться на других сайтах


21.03.2022 в 01:54, nikoshot сказал:

напишите echo $_SERVER['REQUEST_URI'];

и посмотрите что выводится и сравните с вашим условием...

не выдает вообще ничего...

Подозреваю что дело в том, что магазин на OC 3x и twig

Ссылка на комментарий
Поделиться на других сайтах


в контроллере проверяем ид статьи

 

типа 

$data['show_script'] = $information_id == 3; (ваш ид статьи)

 

в шаблоне выводим

 

{% if show_script %}

скрипт

{% endif %}

  • +1 1
Ссылка на комментарий
Поделиться на других сайтах

20.03.2022 в 20:27, dofus сказал:
<? if ($_SERVER['REQUEST_URI']=="/delivery") {
//здесь ваш код
}
?>

Это нужно прописать в контроллере.

if ($_SERVER['REQUEST_URI']=="/delivery") {
//здесь ваш код, например

$data['custom_cod']=',бла-бла-бла';
}

Соответственно в шаблоне

{% if custom_cod %} {{custom_cod}}{% endif %}

  • +1 1
Ссылка на комментарий
Поделиться на других сайтах

есть ещё this request server 

и вообще по урл это как то тупо проверять 

потом добавится язык ещё или сменится адрес и вся магия закончится 

  • +1 1
Ссылка на комментарий
Поделиться на других сайтах

21.03.2022 в 22:45, Blast сказал:

twig же должен быть. какой tpl? php не выполнится

{% if app.request.uri == '/delivery' %}

// код

{% endif %}

Сделал в точности как Вы сказали, но скрипт пропал со всех информационных страниц и на странице /delivery не появился(

Я понимаю что дело во мне и что я затупок, но хотелось бы найти место, где я туплю

Ссылка на комментарий
Поделиться на других сайтах


21.03.2022 в 22:25, spectre сказал:

в контроллере проверяем ид статьи

 

типа 

$data['show_script'] = $information_id == 3; (ваш ид статьи)

 

в шаблоне выводим

 

{% if show_script %}

скрипт

{% endif %}

Так же скрипт пропадает со всех страниц, и нигде не появляется

Ссылка на комментарий
Поделиться на других сайтах


22.03.2022 в 09:32, esculapra сказал:

Это нужно прописать в контроллере.

if ($_SERVER['REQUEST_URI']=="/delivery") {
//здесь ваш код, например

$data['custom_cod']=',бла-бла-бла';
}

Соответственно в шаблоне

{% if custom_cod %} {{custom_cod}}{% endif %}

Тоже не работает =((

Ссылка на комментарий
Поделиться на других сайтах


В 22.03.2022 в 21:03, dofus сказал:

Так же скрипт пропадает со всех страниц, и нигде не появляется

это всего лишь значит что вы что-то не так делаете

Ссылка на комментарий
Поделиться на других сайтах

22.03.2022 в 22:02, dofus сказал:

Сделал в точности как Вы сказали, но скрипт пропал со всех информационных страниц и на странице /delivery не появился(

Я понимаю что дело во мне и что я затупок, но хотелось бы найти место, где я туплю

может без слэша

выведите url  и посмотрите что в нем

{{ app.request.uri }}

Ссылка на комментарий
Поделиться на других сайтах

22.03.2022 в 22:08, spectre сказал:

это всего лишь значит что вы что-то не так делаете

Я об этом и говорю. Причем всё очень плачевно

Ссылка на комментарий
Поделиться на других сайтах


22.03.2022 в 22:20, Blast сказал:

может без слэша

выведите url  и посмотрите что в нем

{{ app.request.uri }}

вот либо лыжи не едут, либо я совсем тугой

Мало того что этот код ничего не выдал

Я создал копию information.twig и information.php

Скорректировал контроллер

Создал макет в админке

 

ииии все равно выдает пустую информационную страницу без нужного скрипта

 

я хз

Ссылка на комментарий
Поделиться на других сайтах


23.03.2022 в 21:27, dofus сказал:

вот либо лыжи не едут, либо я совсем тугой

Мало того что этот код ничего не выдал

Я создал копию information.twig и information.php

Скорректировал контроллер

Создал макет в админке

 

ииии все равно выдает пустую информационную страницу без нужного скрипта

 

я хз

Напишите в лс.. Завтра смогу помочь..

Ссылка на комментарий
Поделиться на других сайтах


23.03.2022 в 21:27, dofus сказал:

вот либо лыжи не едут, либо я совсем тугой

Мало того что этот код ничего не выдал

Я создал копию information.twig и information.php

Скорректировал контроллер

Создал макет в админке

 

ииии все равно выдает пустую информационную страницу без нужного скрипта

 

я хз

 

Лыжи нужно смазывать.

 

21.03.2022 в 21:03, dofus сказал:

Был бы рад, если было бы так просто

НО

Код вставленный через редактор не работает

 

 

Конечно не будет работать - он кривой.

Вот как нужно:

Скрытый текст
<div class="page">
  <div class="pcss3t pcss3t-effect-scale pcss3t-theme-1">
    <input type="radio" name="pcss3t" checked="" id="tab1" class="tab-content-first">
    <label for="tab1"><img src="https://amalora.ru/sdek.jpg" style="width: 100px;"></label>
    <input type="radio" name="pcss3t" id="tab2" class="tab-content-2">
    <label for="tab2"><img src="https://amalora.ru/bb.jpg" style="width: 100px;"></label>
    <input type="radio" name="pcss3t" id="tab3" class="tab-content-3">
    <label for="tab3"><img src="https://amalora.ru/or.jpg" style="width: 100px;"></label>
    <input type="radio" name="pcss3t" id="tab5" class="tab-content-last">
    <label for="tab5"><img src="https://amalora.ru/pr.jpg" style="width: 100px;"></label>
    <ul>
      <li class="tab-content tab-content-first typography">
        <h1>Nikola Tesla</h1>
        <p></p>
      </li>
      <li class="tab-content tab-content-2 typography" style="height: 740px;">
        <p>Стоимость доставки рассчитывается для заказа стоимостью 2500 рублей и весом 1 кг.<br />Точную стоимость доставки Вы можете узнать при оформлении заказа</p>
        <p><div id="boxberry_map"></div></p>
      </li>
      <li class="tab-content tab-content-3 typography">
        <h1>Albert Einstein</h1>
        <p>German-born theoretical physicist who developed the general theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). While best known for his mass–energy equivalence formula E = mc2 (which has been dubbed "the world's most famous equation"), he received the 1921 Nobel Prize in Physics "for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect". The latter was pivotal in establishing quantum theory.</p>
        <p>Near the beginning of his career, Einstein thought that Newtonian mechanics was no longer enough to reconcile the laws of classical mechanics with the laws of the electromagnetic field. This led to the development of his special theory of relativity. He realized, however, that the principle of relativity could also be extended to gravitational fields, and with his subsequent theory of gravitation in 1916, he published a paper on the general theory of relativity.</p>
        <p class="text-right"><em>Find out more about Albert Einstein from <a href="https://en.wikipedia.org/wiki/Albert_Einstein" rel="noreferrer noopener" target="_blank">Wikipedia</a>.</em></p>				
      </li>
      <li class="tab-content tab-content-last typography">
        <div class="typography">
          <h1>Isaac Newton</h1>
          <p>English physicist and mathematician who is widely regarded as one of the most influential scientists of all time and as a key figure in the scientific revolution. His book Philosophiæ Naturalis Principia Mathematica ("Mathematical Principles of Natural Philosophy"), first published in 1687, laid the foundations for most of classical mechanics. Newton also made seminal contributions to optics and shares credit with Gottfried Leibniz for the invention of the infinitesimal calculus.</p>
          <p>Newton's Principia formulated the laws of motion and universal gravitation that dominated scientists' view of the physical universe for the next three centuries. It also demonstrated that the motion of objects on the Earth and that of celestial bodies could be described by the same principles. By deriving Kepler's laws of planetary motion from his mathematical description of gravity, Newton removed the last doubts about the validity of the heliocentric model of the cosmos.</p>
          <p class="text-right"><em>Find out more about Isaac Newton from <a href="https://en.wikipedia.org/wiki/Isaac_Newton" rel="noreferrer noopener" target="_blank">Wikipedia</a>.</em></p>		
        </div>
      </li>
    </ul>
  </div>
</div>
<script type="text/javascript">
/* Описать функцию callback_function, например: */
function callback_function(result) {
	/* Что бы избежать проблемы с кириллическими символами, на страницах отличными от UTF8, вы можете использовать функцию encodeURIComponent() */
	result.name = encodeURIComponent(result.name);

	var element;

	element = document.getElementById('city');
	if ('name' in result && element) {
		element.innerHTML = result.name;
	}
	element = document.getElementById('js-pricedelivery');
	if ('price' in result && element && result.price) {
		element.innerHTML = result.price;
	}
	element = document.getElementById('code_pvz');
	if ('id' in result && element) {
		element.innerHTML = result.id;
	}
	element = document.getElementById('name');
	if ('name' in result && element) {
		element.innerHTML = result.name;
	}
	element = document.getElementById('address');
	if ('address' in result && element) {
		element.innerHTML = result.address;
	}
	element = document.getElementById('workschedule');
	if ('workschedule' in result && element) {
		element.innerHTML = result.workschedule;
	}
	element = document.getElementById('phone');
	if ('phone' in result && element) {
		element.innerHTML = result.phone;
	}
	element = document.getElementById('period');
	if ('period' in result && element) {
		element.innerHTML = result.period;
	}

	if ('prepaid' in result && result.prepaid == '1') {
		alert('Отделение работает только по предоплате!');
	}
}

if ('boxberry' in window) {
	boxberry.openOnPage('boxberry_map');
	boxberry.open(callback_function, '1$Yi5bHpD1-g8mdc5UubTuyYKLyDkIck3D','Москва','77737', 2000, 1000, 0, 27, 17, 5);
}
</script>

 

 

Ссылка на комментарий
Поделиться на других сайтах

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас
 Поделиться

  • Сейчас на странице   0 пользователей

    • Нет пользователей, просматривающих эту страницу.
×
×
  • Создать...

Важная информация

На нашем сайте используются файлы cookie и происходит обработка некоторых персональных данных пользователей, чтобы улучшить пользовательский интерфейс. Чтобы узнать для чего и какие персональные данные мы обрабатываем перейдите по ссылке. Если Вы нажмете «Я даю согласие», это означает, что Вы понимаете и принимаете все условия, указанные в этом Уведомлении о Конфиденциальности.