koteyka Posted September 7, 2016 Report Share Posted September 7, 2016 (edited) Выкладываю микроразметку для гугла, если кому нужно.Для index.tpl <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "WebSite", "name": "Название сайта", "alternateName": "Имя компании", "url": "http://domen.ua", "description": "Описание сайта" } </script> <script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Organization", "url": "http://domen.ua", "name": "Имя компании", "logo": "http://domen.ua/design/шаблон/images/logo.png", "contactPoint": [ { "@type": "ContactPoint", "name": "Алексей", "telephone": "+380 11-111-11-11", "contactType": "customer service", "email": "seller@domen.ua", "availableLanguage": "RU", //язык сайта "areaServed" : "UA" //распложение сайта RU, BY, UA и т.д. },{ "@type": "ContactPoint", "name": "Алексей", "telephone": "+380 22-222-22-22", "contactType": "customer service", "email": "seller@domen.ua", "availableLanguage": "RU", //язык сайта "areaServed" : "UA" //распложение сайта RU, BY, UA и т.д. },{ "@type": "ContactPoint", "name": "Алексей", "telephone": "+380 33-333-33-33", "contactType": "customer service", "email": "seller@domen.ua", "availableLanguage": "RU", //язык сайта "areaServed" : "UA" //распложение сайта RU, BY, UA и т.д. }], "description": "Описание сайта", "address": { "@type": "PostalAddress", "addressLocality": "Днепр, Украина" // Город, страна } } </script> product.tpl <script type="application/ld+json"> { "@context": "http://schema.org/", "@type": "Product", "name": "{/literal}{$product->name}{literal}", "image": "{/literal}{$product->image->filename|resize:800:600:w}{literal}", "description": "{/literal}{$product->description}{literal}", "mpn": "{/literal}{$product->variant->sku}{literal}", "brand": { "@type": "Brand", "name": "{/literal}{$product->brand->name}{literal}" }, "aggregateRating": { "@type": "AggregateRating", "ratingValue": "4.4", //Если на сайте сделан рейтинг товаров, то можно вывести сюда "{/literal}{$product->rate}{literal}" "reviewCount": "89" // тоже самое с количеством голосов }, "offers": { "@type": "Offer", "priceCurrency": "UAH", //Валюта "price": "{/literal}{$product->variant->price}{literal}", "priceValidUntil": "{/literal}{$smarty.now|date_format:"%Y-%m-%d"}{literal}", "itemCondition": "http://schema.org/UsedCondition", "availability": "http://schema.org/InStock", "seller": { "@type": "Organization", "name": "Имя сайта" } } } </script> post.tpl <script type="application/ld+json"> { "@context" : "http://schema.org", "@type" : "Article", "name" : "{/literal}{$post->name}{literal}", "author" : { "@type" : "Person", "name" : "Имя сайта или автор темы" }, "headline" : "{/literal}{$post->name}{literal}", "datePublished" : "{/literal}{$post->date}{literal}", "mainEntityOfPage": {"@type": "WebPage", "@id": "http://domen.ua/blog"}, "dateModified" : "{/literal}{$post->date}{literal}", "image" : "http://domen.ua/files/posts/{/literal}{$post->image}{literal}", "articleBody" : "{/literal}{$post->annotation}{literal}", "url" : "{/literal}{$post->url}{literal}", "publisher" : { "@type" : "Organization", "name" : "Имя сайта", "logo" : "http://domen.ua/design/шаблон/images/logo.png" } } </script> Все скрипты заключить в {literal}......{/literal} Пересмотрите все значения, типа Имя сайта, domen, шаблон и т.д., и замените на нужные. Edited September 7, 2016 by koteyka Quote Link to post Share on other sites
Maksclub Posted September 7, 2016 Report Share Posted September 7, 2016 (edited) Супер! В список доработок, которые нужно сделать сразу после установки Вопрос _ Несколько контактов ContactPoint в index.tpl по какому принципу отображаются в гугле? Edited September 7, 2016 by Maksclub Quote Link to post Share on other sites
koteyka Posted September 7, 2016 Author Report Share Posted September 7, 2016 (edited) Вопрос _ Несколько контактов ContactPoint в index.tpl по какому принципу отображаются в гугле?Точно не скажу, еще не проиндексировались страницы, но валидатор принимает нормально Единственное, что микроразметка постов блога имеет два предупреждения, но я ни как не могу понять, почему. Всю инфу уже перерыл. Хотя валидатор яндекса ошибок или предупреждений не показывает. Там всё нормально. Edited September 7, 2016 by koteyka Quote Link to post Share on other sites
Maksclub Posted September 7, 2016 Report Share Posted September 7, 2016 Раздел можно расширить: "address": { "@type": "PostalAddress", "addressLocality": "Россия, г.Мухобойск", // Город, страна "streetAddress": "ул. Мухобойская,69 оф.69", // Адрес "postalCode": "696969" // Почтовый индекс } Quote Link to post Share on other sites
WebWC Posted September 7, 2016 Report Share Posted September 7, 2016 А есть ли готовая разметка для хлебных крошек?Пример: <ol vocab="http://schema.org/" typeof="BreadcrumbList"> <li property="itemListElement" typeof="ListItem"> <a property="item" typeof="WebPage" href="https://example.com/arts"> <span property="name">Arts</span></a> <meta property="position" content="1"> </li> › <li property="itemListElement" typeof="ListItem"> <a property="item" typeof="WebPage" href="https://example.com/arts/books"> <span property="name">Books</span></a> <meta property="position" content="2"> </li> › <li property="itemListElement" typeof="ListItem"> <a property="item" typeof="WebPage" href="https://example.com/arts/books/poetry"> <span property="name">Poetry</span></a> <meta property="position" content="3"> </li> </ol> Quote Link to post Share on other sites
Maksclub Posted September 7, 2016 Report Share Posted September 7, 2016 А есть ли готовая разметка для хлебных крошек?Пример: http://forum.simplacms.ru/topic/2697-%D1%81%D0%BD%D0%B8%D0%BF%D0%BF%D0%B5%D1%82%D1%8B-%D0%B4%D0%BB%D1%8F-google-%D1%85%D0%BB%D0%B5%D0%B1%D0%BD%D1%8B%D0%B5-%D0%BA%D1%80%D0%BE%D1%88%D0%BA%D0%B8/ Quote Link to post Share on other sites
koteyka Posted September 7, 2016 Author Report Share Posted September 7, 2016 (edited) Раздел можно расширить:Да, можно. Просто в моем случае офиса у сайта нет, а что подробный адрес нужен будет другим людям, не сообразил. Спасибо за дополнение. Edited September 7, 2016 by koteyka Quote Link to post Share on other sites
koteyka Posted September 8, 2016 Author Report Share Posted September 8, 2016 (edited) Нашел причину предупреждений по image. Код в post.tpl должен выглядеть так <script type="application/ld+json"> { "@context" : "http://schema.org", "@type" : "Article", "name" : "{/literal}{$post->name}{literal}", "author" : { "@type" : "Person", "name" : "ИМЯ САЙТА" }, "headline" : "{/literal}{$post->name}{literal}", "datePublished" : "{/literal}{$post->date}{literal}", "mainEntityOfPage": {"@type": "WebPage", "@id": "http://ДОМЕН/blog"}, "dateModified" : "{/literal}{$post->date}{literal}", "image" : { "@type" : "ImageObject", "url" : "http://ДОМЕН/files/posts/{/literal}{$post->image}{literal}", "height" : "640", "width" : "640" }, "articleBody" : "{/literal}{$post->annotation}{literal}", "url" : "{/literal}{$post->url}{literal}", "articleSection" : "КАТЕГОРИЯ ПОСТА ИЛИ СТАТЬИ", "publisher" : { "@type" : "Organization", "name" : "НАЗВАНИЕ ОРГАНИЗАЦИИ", "logo" : { "@type" : "ImageObject", "url" : "http://ДОМЕН/design/trizzy/images/logo.png", "height" : "102", "width" : "75" } } } </script> Edited September 8, 2016 by koteyka Quote Link to post Share on other sites
zikkit Posted September 21, 2016 Report Share Posted September 21, 2016 У меня показывает ошибку с брендом Что не так, как исправить? Quote Link to post Share on other sites
koteyka Posted September 21, 2016 Author Report Share Posted September 21, 2016 В ProductView.php после // Категория и бренд товара $product->categories = $this->categories->get_categories(array('product_id'=>$product->id)); добавить $product->brand = $this->brands->get_brand(intval($product->brand_id)); Quote Link to post Share on other sites
mishanya Posted September 21, 2016 Report Share Posted September 21, 2016 В ProductView.php после // Категория и бренд товара $product->categories = $this->categories->get_categories(array('product_id'=>$product->id)); добавить $product->brand = $this->brands->get_brand(intval($product->brand_id)); не проще заменить {$product->brand->name} на {$brand->name} и не выбирать второй раз бренд. Quote Link to post Share on other sites
koteyka Posted September 21, 2016 Author Report Share Posted September 21, 2016 (edited) Да, проще. На том сайте, для которого я это делал, почему-то строка выбора бренда была удалена из ProductView.php, а с дефолтным файлом я не сравнивал. Edited September 21, 2016 by koteyka Quote Link to post Share on other sites
zikkit Posted September 21, 2016 Report Share Posted September 21, 2016 (edited) Спасибо за быстрый ответ. В post при двух ваших вариантах ошибка такая Edited September 21, 2016 by zikkit Quote Link to post Share on other sites
koteyka Posted September 21, 2016 Author Report Share Posted September 21, 2016 Попробуйте в скрипте заменить кавычки на одинарные. У Вас в теле поста есть кавычки, а само тело обернуто в кавычки скрипта. Идет конфликт. Quote Link to post Share on other sites
zikkit Posted September 21, 2016 Report Share Posted September 21, 2016 Так же по первому вопросу. А если есть товар без бренда и выдает ошибку То так можно оставить или есть вариант решения? Quote Link to post Share on other sites
koteyka Posted September 21, 2016 Author Report Share Posted September 21, 2016 (edited) Перед скриптом добавьте {if !$brand}{$brand->name = 'Нет бренда'}{/if} либо {if !$prosuct->brand}{$prosuct->brand->name = 'Нет бренда'}{/if} смотря, как вы прописали в скрипте. Edited September 21, 2016 by koteyka Quote Link to post Share on other sites
zikkit Posted September 21, 2016 Report Share Posted September 21, 2016 Что-то не реагирует оно никак. Ставил уже и перед и после <script type="application/ld+json"> оба варианта. Если поставить за {literal}. Кстати, я правильно понимаю, что ваш второй поста за 08.09.2016 - 10:10 стоит использовать для правок post.tpl? Quote Link to post Share on other sites
koteyka Posted September 21, 2016 Author Report Share Posted September 21, 2016 Если поставить за {literal}.Нужно до литерала. Туда, где обычный код шаблона.Кстати, я правильно понимаю, что ваш второй поста за 08.09.2016 - 10:10 стоит использовать для правок post.tpl?Да. Quote Link to post Share on other sites
zikkit Posted September 21, 2016 Report Share Posted September 21, 2016 (edited) Спасибо за ответы. Но у меня белый экран в таком случае, что с первым вариантом, что со вторым. В чем может быть причина? Edited September 21, 2016 by zikkit Quote Link to post Share on other sites
Maksclub Posted September 22, 2016 Report Share Posted September 22, 2016 Спасибо за ответы. Но у меня белый экран в таком случае, что с первым вариантом, что со вторым. В чем может быть причина? Скиньте кусок кода. Там хитро с литералами, в середине кода нужно неожиданно закрыть, вывести переменную и снова открыть Quote Link to post Share on other sites
service79 Posted September 22, 2016 Report Share Posted September 22, 2016 хм.... у меня тоже {if !$brand}{$brand->name = 'Нет бренда'}{/if} выдает белый экран... не важно где ставить в коде шаблона.. даже просто саму надпись вывести "нет бренда" не дает - ошибка в самой конструкции условия? Quote Link to post Share on other sites
Maksclub Posted September 22, 2016 Report Share Posted September 22, 2016 (edited) хм.... у меня тоже {if !$brand}{$brand->name = 'Нет бренда'}{/if} выдает белый экран... не важно где ставить в коде шаблона.. даже просто саму надпись вывести "нет бренда" не дает - ошибка в самой конструкции условия? {if $brand}{else}Нет бренда{/if} Edited September 22, 2016 by Maksclub Quote Link to post Share on other sites
koteyka Posted September 23, 2016 Author Report Share Posted September 23, 2016 (edited) {if $brand}{else}Нет бренда{/if}Такая конструкция выведет надпись в шаблон, но переменная $brand->name всё равно останется пустой. Тогда уже лучше так {if !$brand} {$p_brand = 'Не известен'} {else} {$p_brand = $brand->name} {/if} и в скрипте указывать не $brand->name, а $p_brand. А не работала конструкция потому, что переменная $brand - это массив и мы пытались 'Не известен' всунуть в массив и делали это не правильно. Edited September 23, 2016 by koteyka Quote Link to post Share on other sites
Kors Posted September 23, 2016 Report Share Posted September 23, 2016 Перед скриптом добавьте {if !$brand}{$brand->name = 'Нет бренда'}{/if}либо{if !$prosuct->brand}{$prosuct->brand->name = 'Нет бренда'}{/if}смотря, как вы прописали в скрипте. Совсем неправильно и плохо:1. Не будет работать, так как нарушает правила Smarty.2. Изменять данные в шаблоне в принципе неправильно. Шаблон предназначен для ВЫВОДА только. Если нужно, то надо менять во view/*.php Такая конструкция выведет надпись в шаблон, но переменная $brand->name всё равно останется пустой. Тогда уже лучше так {if !$brand} {$p_brand = 'Не известен'} {else} {$p_brand = $brand->name} {/if}и в скрипте указывать не $brand->name, а $p_brand. А не работала конструкция потому, что переменная $brand - это массив и мы пытались 'Не известен' всунуть в массив и делали это не правильно. 3. Переменная $brand - совсем не массив.4. "переменная $brand->name всё равно останется пустой" - а зачем ее менять-то?5. Maksclub напомнил Вам про типовую простую шаблонную конструкцию {if $brand}{else}Нет бренда{/if} - применяется в шаблонах в десятках мест. Зачем велосипед изобретаете? Quote Link to post Share on other sites
service79 Posted September 23, 2016 Report Share Posted September 23, 2016 {if $brand}{else}Нет бренда{/if} Все верно - работает: {/literal}{if $brand}{$brand->name|escape}{else}Нет бренда{/if}{literal} Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.