Перейти к публикации
  • разработка интернет магазинов на opencart
  • доработка интернет магазинов на opencart

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


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 в 21:03, dofus сказал:

Тоже не рилииет

Посмотри лог ошипотому чток.

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

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>

 

 

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

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

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

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

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

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

Войти

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

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

×
×
  • Создать...

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

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