[11/06/2024] Les premières modifs + installation de quelques modules indispensables
This commit is contained in:
52
domokits/local/modules/ShortCodeMeta/Config/config.xml
Normal file
52
domokits/local/modules/ShortCodeMeta/Config/config.xml
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<config xmlns="http://thelia.net/schema/dic/config"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
|
||||
|
||||
<loops>
|
||||
<!-- sample definition
|
||||
<loop name="MySuperLoop" class="ShortCodeMeta\Loop\MySuperLoop" />
|
||||
-->
|
||||
</loops>
|
||||
|
||||
<forms>
|
||||
<!--
|
||||
<form name="MyFormName" class="ShortCodeMeta\Form\MySuperForm" />
|
||||
-->
|
||||
</forms>
|
||||
|
||||
<commands>
|
||||
<!--
|
||||
<command class="ShortCodeMeta\Command\MySuperCommand" />
|
||||
-->
|
||||
</commands>
|
||||
|
||||
<services>
|
||||
<service id="shortcodemeta.shortcode.listener" class="ShortCodeMeta\EventListener\ShortCodeListener">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
<service id="shortcodemeta.plugin" class="ShortCodeMeta\Smarty\Plugins\ShortCodeMetaPlugin">
|
||||
<argument type="service" id="service_container" />
|
||||
<tag name="thelia.parser.register_plugin"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
<hooks>
|
||||
<hook id="shortcodemeta.front.hook">
|
||||
<tag name="hook.event_listener" event="main.head-bottom" type="front" templates="render:short_code_meta_hook.html" />
|
||||
</hook>
|
||||
</hooks>
|
||||
|
||||
<!--
|
||||
<exports>
|
||||
|
||||
</exports>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<imports>
|
||||
|
||||
</imports>
|
||||
-->
|
||||
</config>
|
||||
40
domokits/local/modules/ShortCodeMeta/Config/module.xml
Normal file
40
domokits/local/modules/ShortCodeMeta/Config/module.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module xmlns="http://thelia.net/schema/dic/module"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://thelia.net/schema/dic/module http://thelia.net/schema/dic/module/module-2_2.xsd">
|
||||
<fullnamespace>ShortCodeMeta\ShortCodeMeta</fullnamespace>
|
||||
<descriptive locale="en_US">
|
||||
<title>Add meta to header by short code</title>
|
||||
<!--
|
||||
<subtitle></subtitle>
|
||||
<description></description>
|
||||
<postscriptum></postscriptum>
|
||||
-->
|
||||
</descriptive>
|
||||
<descriptive locale="fr_FR">
|
||||
<title>Ajoute des méta-données au header par les short codes</title>
|
||||
</descriptive>
|
||||
<!-- <logo></logo> -->
|
||||
<!--<images-folder>images</images-folder>-->
|
||||
<languages>
|
||||
<language>en_US</language>
|
||||
<language>fr_FR</language>
|
||||
</languages>
|
||||
<version>2.0.0</version>
|
||||
<authors>
|
||||
<author>
|
||||
<name>Vincent Lopes-Vicente</name>
|
||||
<email>vlopes@openstudio.fr</email>
|
||||
</author>
|
||||
</authors>
|
||||
<type>classic</type>
|
||||
|
||||
<required>
|
||||
<module>ShortCode</module>
|
||||
</required>
|
||||
|
||||
<thelia>2.5.0</thelia>
|
||||
<stability>other</stability>
|
||||
<mandatory>0</mandatory>
|
||||
<hidden>0</hidden>
|
||||
</module>
|
||||
31
domokits/local/modules/ShortCodeMeta/Config/routing.xml
Normal file
31
domokits/local/modules/ShortCodeMeta/Config/routing.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||
|
||||
<!--
|
||||
|
||||
if a /admin/module/shortcodemeta/ route is provided, a "Configuration" button will be displayed
|
||||
for the module in the module list. Clicking this button will invoke this route.
|
||||
|
||||
<route id="my_route_id" path="/admin/module/shortcodemeta">
|
||||
<default key="_controller">ShortCodeMeta\Full\Class\Name\Of\YourConfigurationController::methodName</default>
|
||||
</route>
|
||||
|
||||
<route id="my_route_id" path="/admin/module/shortcodemeta/route-name">
|
||||
<default key="_controller">ShortCodeMeta\Full\Class\Name\Of\YourAdminController::methodName</default>
|
||||
</route>
|
||||
|
||||
<route id="my_route_id" path="/my/route/name">
|
||||
<default key="_controller">ShortCodeMeta\Full\Class\Name\Of\YourOtherController::methodName</default>
|
||||
</route>
|
||||
|
||||
...add as many routes as required.
|
||||
|
||||
<route>
|
||||
...
|
||||
</route>
|
||||
-->
|
||||
|
||||
</routes>
|
||||
30
domokits/local/modules/ShortCodeMeta/Config/schema.xml
Normal file
30
domokits/local/modules/ShortCodeMeta/Config/schema.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="TheliaMain"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="../../../vendor/propel/propel/resources/xsd/database.xsd" >
|
||||
<!--
|
||||
See propel documentation on http://propelorm.org for all information about schema file
|
||||
|
||||
<table name="product_rel" namespace="ShortCodeMeta\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column defaultValue="0" name="visible" required="true" type="TINYINT" />
|
||||
<column defaultValue="0" name="position" required="true" type="INTEGER" />
|
||||
<column name="title" size="255" type="VARCHAR" />
|
||||
<column name="description" type="CLOB" />
|
||||
<column name="chapo" type="LONGVARCHAR" />
|
||||
<column name="postscriptum" type="LONGVARCHAR" />
|
||||
<foreign-key foreignTable="product" name="fk_product_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="product_id" />
|
||||
</foreign-key>
|
||||
<behavior name="timestampable" />
|
||||
<behavior name="i18n">
|
||||
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
|
||||
</behavior>
|
||||
<behavior name="versionable">
|
||||
<parameter name="log_created_at" value="true" />
|
||||
<parameter name="log_created_by" value="true" />
|
||||
</behavior>
|
||||
</table>
|
||||
-->
|
||||
<external-schema filename="local/config/schema.xml" referenceOnly="true" />
|
||||
</database>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ShortCodeMeta\EventListener;
|
||||
|
||||
|
||||
use ShortCode\Event\ShortCodeEvent;
|
||||
use ShortCodeMeta\ShortCodeMeta;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
class ShortCodeListener implements EventSubscriberInterface
|
||||
{
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return [
|
||||
ShortCodeMeta::EMPTY_PAGE_META_SHORT_CODE => [['checkEmptyPage', 128]],
|
||||
ShortCodeMeta::PAGINATION_META_SHORT_CODE => [['addPaginationMeta', 128]],
|
||||
];
|
||||
}
|
||||
|
||||
public function addPaginationMeta(ShortCodeEvent $event)
|
||||
{
|
||||
$attributes = $event->getAttributes();
|
||||
|
||||
if (!isset($attributes['rel'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rel = $attributes['rel'];
|
||||
|
||||
$staticVariableName = strtoupper($attributes['rel']).'_PAGE_URL';
|
||||
|
||||
if (null !== $url = ShortCodeMeta::$$staticVariableName) {
|
||||
$event->setResult('<link rel="'.$rel.'" href="'.$url.'">');
|
||||
}
|
||||
}
|
||||
|
||||
public function checkEmptyPage(ShortCodeEvent $event)
|
||||
{
|
||||
if (ShortCodeMeta::$IS_EMPTY_PAGE === true) {
|
||||
$event->setResult('<meta name="robots" content="noindex, nofollow">');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
4
domokits/local/modules/ShortCodeMeta/I18n/en_US.php
Executable file
4
domokits/local/modules/ShortCodeMeta/I18n/en_US.php
Executable file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
// 'an english string' => 'The displayed english string',
|
||||
);
|
||||
4
domokits/local/modules/ShortCodeMeta/I18n/fr_FR.php
Executable file
4
domokits/local/modules/ShortCodeMeta/I18n/fr_FR.php
Executable file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
// 'an english string' => 'La traduction française de la chaine',
|
||||
);
|
||||
21
domokits/local/modules/ShortCodeMeta/LICENSE
Normal file
21
domokits/local/modules/ShortCodeMeta/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 OpenStudio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
54
domokits/local/modules/ShortCodeMeta/Readme.md
Normal file
54
domokits/local/modules/ShortCodeMeta/Readme.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Short Code Meta
|
||||
|
||||
ShortCodeMeta allow you to add meat in head for
|
||||
- Empty page (`noindex, nofollow`)
|
||||
- Pagination link
|
||||
|
||||
## Installation
|
||||
|
||||
### Manually
|
||||
|
||||
* Copy the module into ```<thelia_root>/local/modules/``` directory and be sure that the name of the module is ShortCodeMeta.
|
||||
* Activate it in your thelia administration panel
|
||||
|
||||
### Composer
|
||||
|
||||
Add it in your main thelia composer.json file
|
||||
|
||||
```
|
||||
composer require thelia/short-code-meta-module:~1.0
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This module use ShortCode (https://github.com/thelia-modules/ShortCode) to add metas in head after smarty has completly build the page.
|
||||
The short codes are automatically added in templates with the hook `main.head-bottom` so be sure you have this hook in your template layout.
|
||||
|
||||
### Empty pages
|
||||
|
||||
To add a meta `noindex, nofollow` to an empty page you have to inform the module with the smarty tag `{set_empty_page_meta}`
|
||||
All the page where this tag is present will have a noindex meta.
|
||||
For example if you use a loop product in your category page you can add this tag in your elseloop like this :
|
||||
```
|
||||
{ifloop rel="product_list"}
|
||||
<div class="row">
|
||||
{loop type="product" name="product_list" category=$category_id}
|
||||
<p>{$TITLE}
|
||||
{/loop}
|
||||
</div>
|
||||
{/ifloop}
|
||||
{elseloop rel="product_list"}
|
||||
{set_empty_page_meta}
|
||||
{/elseloop}
|
||||
```
|
||||
With this, all categories page without products will not be indexed by robots.
|
||||
|
||||
|
||||
### Pagination meta link
|
||||
|
||||
To add a `<link rel="prev" href="http://url_of_prev_page>` or `<link rel="next" href="http://url_of_next_page>` in your head you just have to add the smarty tag with the good url :
|
||||
`{set_prev_page_meta_link url={$url}}` for the prev link
|
||||
`{set_next_page_meta_link url={$url}}` for the next link
|
||||
|
||||
|
||||
|
||||
41
domokits/local/modules/ShortCodeMeta/ShortCodeMeta.php
Normal file
41
domokits/local/modules/ShortCodeMeta/ShortCodeMeta.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace ShortCodeMeta;
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionInterface;
|
||||
use ShortCode\ShortCode;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
class ShortCodeMeta extends BaseModule
|
||||
{
|
||||
public static $IS_EMPTY_PAGE = false;
|
||||
|
||||
public static $PREV_PAGE_URL = null;
|
||||
public static $NEXT_PAGE_URL = null;
|
||||
|
||||
/** @var string */
|
||||
const DOMAIN_NAME = 'shortcodemeta';
|
||||
|
||||
const EMPTY_PAGE_META_SHORT_CODE = 'meta_short_code_empty_page';
|
||||
const PAGINATION_META_SHORT_CODE = 'meta_short_code_pagination';
|
||||
|
||||
public static function setStatic($name) {
|
||||
return self::$$name;
|
||||
}
|
||||
|
||||
public function postActivation(ConnectionInterface $con = null): void
|
||||
{
|
||||
ShortCode::createNewShortCodeIfNotExist(self::EMPTY_PAGE_META_SHORT_CODE, self::EMPTY_PAGE_META_SHORT_CODE);
|
||||
ShortCode::createNewShortCodeIfNotExist(self::PAGINATION_META_SHORT_CODE, self::PAGINATION_META_SHORT_CODE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace ShortCodeMeta\Smarty\Plugins;
|
||||
|
||||
|
||||
use ShortCodeMeta\ShortCodeMeta;
|
||||
use TheliaSmarty\Template\AbstractSmartyPlugin;
|
||||
use TheliaSmarty\Template\SmartyPluginDescriptor;
|
||||
|
||||
class ShortCodeMetaPlugin extends AbstractSmartyPlugin
|
||||
{
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return [
|
||||
new SmartyPluginDescriptor('function', 'set_empty_page_meta', $this, 'setEmptyPageMeta'),
|
||||
new SmartyPluginDescriptor('function', 'set_prev_page_meta_link', $this, 'setPrevPageMetaLink'),
|
||||
new SmartyPluginDescriptor('function', 'set_next_page_meta_link', $this, 'setNextPageMetaLink')
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param \Smarty_Internal_Template $smarty
|
||||
*/
|
||||
public function setPrevPageMetaLink($params, $smarty)
|
||||
{
|
||||
if (isset($params['url'])) {
|
||||
ShortCodeMeta::$PREV_PAGE_URL = $params['url'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param \Smarty_Internal_Template $smarty
|
||||
*/
|
||||
public function setNextPageMetaLink($params, $smarty)
|
||||
{
|
||||
if (isset($params['url'])) {
|
||||
ShortCodeMeta::$NEXT_PAGE_URL = $params['url'];
|
||||
}
|
||||
}
|
||||
|
||||
public function setEmptyPageMeta()
|
||||
{
|
||||
ShortCodeMeta::$IS_EMPTY_PAGE = true;
|
||||
}
|
||||
}
|
||||
12
domokits/local/modules/ShortCodeMeta/composer.json
Normal file
12
domokits/local/modules/ShortCodeMeta/composer.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "thelia/short-code-meta-module",
|
||||
"license": "LGPL-3.0+",
|
||||
"type": "thelia-module",
|
||||
"require": {
|
||||
"thelia/installer": "~1.1",
|
||||
"thelia/short-code-module": "~2.0.0"
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "ShortCodeMeta"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
[meta_short_code_empty_page]
|
||||
[meta_short_code_pagination rel=prev]
|
||||
[meta_short_code_pagination rel=next]
|
||||
Reference in New Issue
Block a user