liens GET
MrToine Membre non connecté
Booster Bazooka
- Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
Je m'explique, Je suis en train de coder un module de blogs. Quand le membre arrive sur la page blog d'un utilisateur, il y a la liste des articles et il peut cliquer sur l'un d'entre eux pour y voir le dit-article entier et y laisser un commentaire. Seulement le lien 'lire la suite' redirige de nouveau vers la liste des blogs... Je vous laisser la page index du module car je pense que le soucis viens de la regex mais je ne suis pas trop sure...
Code PHP :
<?php /*################################################## * index.php * ------------------- * begin : October, 2014 * copyright : (C) 2014 Anthony VIOLET * email : anthony.violet@outlook.fr * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ define('PATH_TO_ROOT', '..'); require_once PATH_TO_ROOT . '/kernel/init.php'; $url_controller_mappers = array( //Admin new UrlControllerMapper('AdminBlogManageController', '`^/admin/manage`'), //Manager new UrlControllerMapper('BlogCreateController', '`^/create`'), new UrlControllerMapper('CreatorManagerBlogController', '`^/user(?:/([0-9]+))?/manager`', array('user_id')), //Display new UrlControllerMapper('BlogPostController', '`^/post(?:/([0-9]+)-([a-z0-9-_]+))?/?$`', array('post_slug')), new UrlControllerMapper('BlogUserController', '`^/user(?:/([0-9]+))?/?$`', array('user_id')), new UrlControllerMapper('BlogController', '`^.*$`') ); DispatchManager::dispatch($url_controller_mappers);
C'est la ligne d'appel du controller BlogPostController qui permet d'appeler l'article
Édité par MrToine Le 05/10/2017 à 12h45
janus57 Membre non connecté
- Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
- Equipe Assistance
ce comportement est avec ou sans réécriture d'url ?
Il faudrait le controller qui génère les URL aussi car l'erreur est peut être là.
Cordialement, janus57
MrToine Membre non connecté
Booster Bazooka
- Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
Code PHP :
<?php /*################################################## * BlogUrlBuilder.class.php * ------------------- * begin : November 01, 2014 * copyright : (C) 2014 Anthony VIOLET * email : anthony.violet@outlook.fr * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class BlogUrlBuilder { const DEFAULT_SORT_FIELD = ''; const DEFAULT_SORT_MODE = 'desc'; private static $dispatcher = '/blog'; /** * @return Url */ public static function home(){ return DispatchManager::get_url(self::$dispatcher, '/'); } public static function home_site(){ return DispatchManager::get_url(HOST); } public static function blog_user(){ return DispatchManager::get_url(self::$dispatcher, '/user'); } public static function blog_post(){ return DispatchManager::get_url(self::$dispatcher, '/post'); } public static function display_comments_posts($slug_post) { return DispatchManager::get_url(self::$dispatcher, '/post/'.$slug_post.'/', true); } // Manager public static function create_blog(){ return DispatchManager::get_url(self::$dispatcher, '/create'); } public static function manage_blog($user_id){ return DispatchManager::get_url(self::$dispatcher, 'user/'.$user_id.'/manager/'); } } ?>
janus57 Membre non connecté
- Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
- Equipe Assistance
le lien en question ne ferai pas appel à "display_comments_posts" par hasard ?
Il faudrait aussi un exemple de lien et la regex contenu dans le .htaccess généré.
Cordialement, janus57
MrToine Membre non connecté
Booster Bazooka
- Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
Code PHP :
/* Comments */ $comments_topic = new BlogCommentsTopic(); $comments_topic->set_id_in_module($post->get_id()); $comments_topic->set_url(BlogUrlBuilder::display_comments_posts($post->get_slug()));
Serait-ce le problème ? (un changement PBT4.1 > 5.1 ?)
le liens est de cette forme : (mon_site/post/post-slug).
Pour le htaccess, je n'en n'ai pas dans le dossier /blog/ . Est-il généré ailleurs ? Si c'est celui de la racine du site qu'il te faut, alors le voici :
Code PHP :
# Charset # AddDefaultCharset UTF-8 # Hide directory listings # Options -Indexes # Prevent viewing of .htaccess file # <Files .htaccess> # Apache <= 2.3 <IfModule mod_authz_core.c> Require all denied </IfModule> # Apache 2.2 <IfModule !mod_authz_core.c> Order Allow,Deny Deny from all </IfModule> </Files> # HTTP Headers # <IfDefine !Free> <IfModule mod_headers.c> # Don't allow any pages to be framed externally - Defends against CSRF Header set X-Frame-Options SAMEORIGIN # Control Cross-Domain Policies Header set X-Permitted-Cross-Domain-Policies "master-only" # Turn on IE8-IE9 XSS prevention tools Header set X-XSS-Protection "1; mode=block" # Prevent mime based attacks Header always set X-Content-Type-Options "nosniff" # Use this to force IE to hide that annoying browser compatibility button in the address bar. # IE=edge means IE should use the latest (edge) version of its rendering engine. # chrome=1 means IE should use the Chrome rendering engine if installed. BrowserMatch MSIE ie Header set X-UA-Compatible "IE=Edge" </IfModule> </IfDefine> # Rewrite rules # RewriteEngine on RewriteBase / # Core # RewriteRule ^user/pm-?([0-9]+)-?([0-9]{0,})-?([0-9]{0,})-?([0-9]{0,})-?([a-z_]{0,})$ /phpboost_pdk/user/pm.php?pm=$1&id=$2&p=$3"e=$4 [L,QSA] RewriteRule ^admin/cache/([\w/_-]*)$ /phpboost_pdk/admin/cache/index.php?url=/$1 [L,QSA] RewriteRule ^admin/config/([\w/_-]*)$ /phpboost_pdk/admin/config/index.php?url=/$1 [L,QSA] RewriteRule ^admin/content/([\w/_-]*)$ /phpboost_pdk/admin/content/index.php?url=/$1 [L,QSA] RewriteRule ^admin/errors/([\w/_-]*)$ /phpboost_pdk/admin/errors/index.php?url=/$1 [L,QSA] RewriteRule ^admin/files/([\w/_-]*)$ /phpboost_pdk/admin/files/index.php?url=/$1 [L,QSA] RewriteRule ^admin/langs/([\w/_-]*)$ /phpboost_pdk/admin/langs/index.php?url=/$1 [L,QSA] RewriteRule ^admin/maintain/([\w/_-]*)$ /phpboost_pdk/admin/maintain/index.php?url=/$1 [L,QSA] RewriteRule ^admin/member/([\w/_-]*)$ /phpboost_pdk/admin/member/index.php?url=/$1 [L,QSA] RewriteRule ^admin/modules/([\w/_-]*)$ /phpboost_pdk/admin/modules/index.php?url=/$1 [L,QSA] RewriteRule ^admin/server/([\w/_-]*)$ /phpboost_pdk/admin/server/index.php?url=/$1 [L,QSA] RewriteRule ^admin/smileys/([\w/_-]*)$ /phpboost_pdk/admin/smileys/index.php?url=/$1 [L,QSA] RewriteRule ^admin/themes/([\w/_-]*)$ /phpboost_pdk/admin/themes/index.php?url=/$1 [L,QSA] RewriteRule ^syndication/([\w/_-]*)$ /phpboost_pdk/syndication/index.php?url=/$1 [L,QSA] RewriteRule ^user/([\w/-_]*)$ /phpboost_pdk/user/index.php?url=/$1 [L,QSA] # Modules rules # # QuestionCaptcha # RewriteRule ^QuestionCaptcha/([\w/_-]*)$ /phpboost_pdk/QuestionCaptcha/index.php?url=/$1 [L,QSA] # ReCaptcha # RewriteRule ^ReCaptcha/([\w/_-]*)$ /phpboost_pdk/ReCaptcha/index.php?url=/$1 [L,QSA] # database # RewriteRule ^database/([\w/_-]*)$ /phpboost_pdk/database/index.php?url=/$1 [L,QSA] # sandbox # RewriteRule ^sandbox/([\w/_-]*)$ /phpboost_pdk/sandbox/index.php?url=/$1 [L,QSA] # bugtracker # RewriteRule ^bugtracker/([\w/_-]*)$ /phpboost_pdk/bugtracker/index.php?url=/$1 [L,QSA] # blog # RewriteRule ^blog/([\w/_-]*)$ /phpboost_pdk/blog/index.php?url=/$1 [L,QSA] # PHP and HTTP protections # # Block out use of illegal or unsafe characters in the HTTP Request RewriteCond %{THE_REQUEST} ^.*(\r|\n|%0A|%0D).* [NC,OR] # Block out use of illegal or unsafe characters in the Referer Variable of the HTTP Request RewriteCond %{HTTP_REFERER} ^(.*)(<|>|'|%0A|%0D|%27|%3C|%3E|%00).* [NC] RewriteRule .* - [F,L] # Block out any script trying to set a mosConfig value through the URL RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] # Block out any script trying to base64_encode/decode content via URL RewriteCond %{QUERY_STRING} base64_(en|de)code[^(]*\([^)]*\) [OR] # Block out any script that includes a <script> tag in URL RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL RewriteCond %{QUERY_STRING} GLOBALS(=|[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL RewriteCond %{QUERY_STRING} _REQUEST(=|[|\%[0-9A-Z]{0,2}) RewriteRule .* - [F,L] # File and SQL injections protections # RewriteCond %{REQUEST_METHOD} GET RewriteCond %{QUERY_STRING} (;|<|>|'|"|\)|%0A|%0D|%22|%27|%3C|%3E|%00).*(/\*|union|select|insert|cast|set|declare|drop|update|md5|benchmark) [NC,OR] RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http:// [OR] RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=http%3A%2F%2F [OR] RewriteCond %{QUERY_STRING} [a-zA-Z0-9_]=(\.\.//?)+ [OR] RewriteCond %{QUERY_STRING} (localhost|loopback|127\.0\.0\.1) [NC,OR] RewriteCond %{QUERY_STRING} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC] RewriteRule .* - [F,L] # Bandwith protection # RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://localhost RewriteRule .*upload/.*$ - [F] # Stop hotlinking # RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://localhost RewriteRule \.(bmp|gif|jpe?g|png|swf)$ - [F,L,NC] # Bots blocking protection # # URL encoded HTML, see http://www.w3schools.com/tags/ref_urlencode.asp RewriteCond %{HTTP_USER_AGENT} (<|>|'|%0A|%0D|%27|%3C|%3E|%00) [NC,OR] # Address harvesters RewriteCond %{HTTP_USER_AGENT} ^(autoemailspider|ExtractorPro) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^E?Mail.?(Collect|Harvest|Magnet|Reaper|Siphon|Sweeper|Wolf) [NC,OR] RewriteCond %{HTTP_USER_AGENT} (DTS.?Agent|Email.?Extrac) [NC,OR] RewriteCond %{HTTP_REFERER} iaea\.org [NC,OR] # Image-grabbers RewriteCond %{HTTP_USER_AGENT} ^(AcoiRobot|FlickBot|webcollage) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(Express|Mister|Web).?(Web|Pix|Image).?(Pictures|Collector)? [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Image.?(fetch|Stripper|Sucker) [NC,OR] # "Gray-hats" RewriteCond %{HTTP_USER_AGENT} ^(Atomz|BlackWidow|BlogBot|EasyDL|Marketwave|Sqworm|SurveyBot|Webclipping\.com) [NC,OR] RewriteCond %{HTTP_USER_AGENT} (girafa\.com|gossamer\-threads\.com|grub\-client|Netcraft|Nutch) [NC,OR] # Site-grabbers RewriteCond %{HTTP_USER_AGENT} ^(eCatch|(Get|Super)Bot|Kapere|HTTrack|JOC|Offline|UtilMind|Xaldon) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Web.?(Auto|Cop|dup|Fetch|Filter|Gather|Go|Leach|Mine|Mirror|Pix|QL|RACE|Sauger) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Web.?(site.?(eXtractor|Quester)|Snake|ster|Strip|Suck|vac|walk|Whacker|ZIP) [NC,OR] RewriteCond %{HTTP_USER_AGENT} WebCapture [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^DISCo\ Pump [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^NetZIP [NC,OR] # Tools RewriteCond %{HTTP_USER_AGENT} ^(Dart.?Communications|Enfish|htdig|Java|larbin) [NC,OR] RewriteCond %{HTTP_USER_AGENT} (FrontPage|Indy.?Library|RPT\-HTTPClient) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(lwp|www\.thatrobotsite\.com|webbandit|Zeus) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(Microsoft|MFC).(Data|Internet|URL|WebDAV|Foundation).(Access|Explorer|Control|MiniRedir|Class) [NC,OR] # Unknown RewriteCond %{HTTP_USER_AGENT} ^(Crawl_Application|Lachesis|Nutscrape) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^[CDEFPRS](Browse|Eval|Surf) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(Demo|Full.?Web|Lite|Production|Franklin|Missauga|Missigua).?(Bot|Locat) [NC,OR] RewriteCond %{HTTP_USER_AGENT} (efp@gmx\.net|hhjhj@yahoo\.com|lerly\.net|mapfeatures\.net|metacarta\.com) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(Industry|Internet|IUFW|Lincoln|Missouri|Program).?(Program|Explore|Web|State|College|Shareware) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(Mac|Ram|Educate|WEP).?(Finder|Search) [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(Moz+illa|MSIE).?[0-9]?.?[0-9]?[0-9]?$ [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Mozilla/[0-9]\.[0-9][0-9]?.\(compatible[\)\ ] [NC,OR] RewriteCond %{HTTP_USER_AGENT} NaverRobot [NC] RewriteRule .* - [F,L] # Error pages # ErrorDocument 403 /phpboost_pdk/user/error/403/ ErrorDocument 404 /phpboost_pdk/user/error/404/ # Gzip compression # <IfDefine !Free> <IfModule mod_filter.c> <IfModule mod_deflate.c> # Compress HTML, CSS, JavaScript, Text, XML and fonts AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/xml # Remove browser bugs (only needed for really old browsers) BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4\.0[678] no-gzip BrowserMatch \bMSIE !no-gzip !gzip-only-text/html <IfModule mod_headers.c> Header append Vary User-Agent </IfModule> </IfModule> </IfModule> </IfDefine> # Expires Headers # <IfDefine !Free> <IfModule mod_expires.c> ExpiresActive On # Default expiration: 1 week after request ExpiresDefault "access plus 1 week" # CSS and JS expiration: 1 week after request ExpiresByType text/css "access plus 1 week" ExpiresByType text/javascript "access plus 1 week" ExpiresByType text/x-javascript "access plus 1 week" ExpiresByType application/javascript "access plus 1 week" ExpiresByType application/x-javascript "access plus 1 week" # Fonts expiration: 1 week after request <IfModule mod_mime.c> AddType application/font-woff .woff AddType application/font-woff2 .woff2 </IfModule> ExpiresByType application/font-woff "access plus 1 month" ExpiresByType application/font-woff2 "access plus 1 month" # Image files expiration: 1 month after request ExpiresByType image/bmp "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/jp2 "access plus 1 month" ExpiresByType image/pipeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/svg+xml "access plus 1 month" ExpiresByType image/tiff "access plus 1 month" ExpiresByType image/vnd.microsoft.icon "access plus 1 month" ExpiresByType image/x-icon "access plus 1 month" ExpiresByType image/ico "access plus 1 month" ExpiresByType image/icon "access plus 1 month" ExpiresByType text/ico "access plus 1 month" ExpiresByType application/ico "access plus 1 month" ExpiresByType image/vnd.wap.wbmp "access plus 1 month" ExpiresByType application/vnd.wap.wbxml "access plus 1 month" ExpiresByType application/smil "access plus 1 month" # Audio files expiration: 1 month after request ExpiresByType audio/basic "access plus 1 month" ExpiresByType audio/mid "access plus 1 month" ExpiresByType audio/midi "access plus 1 month" ExpiresByType audio/mpeg "access plus 1 month" ExpiresByType audio/x-aiff "access plus 1 month" ExpiresByType audio/x-mpegurl "access plus 1 month" ExpiresByType audio/x-pn-realaudio "access plus 1 month" ExpiresByType audio/x-wav "access plus 1 month" # Movie files expiration: 1 month after request ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType x-world/x-vrml "access plus 1 month" ExpiresByType video/x-msvideo "access plus 1 month" ExpiresByType video/mpeg "access plus 1 month" ExpiresByType video/mp4 "access plus 1 month" ExpiresByType video/quicktime "access plus 1 month" ExpiresByType video/x-la-asf "access plus 1 month" ExpiresByType video/x-ms-asf "access plus 1 month" </IfModule> </IfDefine> # Disable file etags # <IfDefine !Free> FileETag none </IfDefine>
Édité par MrToine Le 05/10/2017 à 13h55
janus57 Membre non connecté
- Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
- Equipe Assistance
Citation :
Seulement le lien 'lire la suite' redirige de nouveau vers la liste des blogs
et ce lien est généré comment alors ?
Cordialement, janus57
MrToine Membre non connecté
Booster Bazooka
- Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
Donc là, on a la liste des articles du blog utilisateur :
Code PHP :
<?php /*################################################## * BlogUserController.class.php * ------------------- * begin : November 02, 2014 * copyright : (C) 2014 Anthony VIOLET * email : anthony.violet@outlook.fr * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class BlogUserController extends ModuleController { private $view, $blog_name, $blog_id, $lang; public function test($var){ if($var != null){ echo '<pre>'; print_r($var); echo '</pre>'; }else{ echo 'Variable not found !'; } } public function execute(HTTPRequestCustom $request) { $this->blog_id = $request->get_getint('user_id'); $this->blog_name = $this->get_blog()->get_name(); $this->init(); $result = PersistenceContext::get_querier()->select('SELECT * FROM '.PREFIX.'blog_articles JOIN '.DB_TABLE_MEMBER.' ON '.DB_TABLE_MEMBER.'.user_id = '.PREFIX.'blog_articles.author_id', array('id' => $this->blog_id) ); while ($row = $result->fetch()) { $blog = new BlogUser(); $blog->set_properties($row); $this->view->assign_block_vars('blogUserPost', $blog->get_array_tpl_vars()); $this->view->put_all(array( 'BLOG_NAME' => $this->blog_name, 'USER' => $row['display_name'], 'LINK_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->absolute(), 'USER_ID' => $row['user_id'], 'USER_LEVEL_CLASS' => UserService::get_level_class($row['level']), )); } $result->dispose(); return $this->generate_response(); } private function init() { $this->lang = LangLoader::get('common', 'blog'); $this->view = new FileTemplate('blog/BlogUserController.tpl'); $this->view->add_lang($this->lang); } private function get_blog(){ $this->blog = BlogService::get_blog($this->blog_id); return $this->blog; } private function generate_response() { $response = new SiteDisplayResponse($this->view); $graphical_environment = $response->get_graphical_environment(); $graphical_environment->set_page_title($this->lang['module_title']); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], BlogUrlBuilder::home()->rel()); $breadcrumb->add($this->blog_name, 'LIEN BLOG'); return $response; } }
TPL :
Code HTML :
<section> <header> <div class="blog_name">{BLOG_NAME}</div> </header> # START blogUserPost # # IF blogUserPost.APPROVED # <article> <header> <h1>{blogUserPost.NAME}</h1> <div class="more"> # IF C_EDIT # <a href="#">Editer</a> # ENDIF # ${LangLoader::get_message('by', 'common')} <a href="{LINK_USER_PROFILE}" class="{USER_LEVEL_CLASS}" # IF C_USER_GROUP_COLOR # style="color:{USER_GROUP_COLOR}" # ENDIF #>{USER} </a> ${LangLoader::get_message('the', 'common')} {blogUserPost.CREATED} </div> </header> <div class="content"> <p>{blogUserPost.SHORT_CONTENT}... <br /> <a href="{@link_blog_post}/{blogUserPost.SLUG}">{@read_more}</a> </p> </div> </article> # ENDIF # # END blogUserPost # </section>
Puis l'affichage des articles quand on clique sur le lien 'lire la suite' : (là où ça coince en gros)
Code PHP :
<?php /*################################################## * BlogPostController.class.php * ------------------- * begin : November 07, 2014 * copyright : (C) 2014 Anthony VIOLET * email : anthony.violet@outlook.fr * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ class BlogPostController extends ModuleController { private $view, $blog_name, $blog_post, $post_name, $lang; public function execute(HTTPRequestCustom $request) { $this->blog_post = $request->get_getint('post_slug'); $this->blog_name = $this->get_blog()->get_name(); $this->init(); $result = BlogService::get_blog_articles($this->blog_post); $post = new BlogUser(); $post->set_properties($result); /* Comments */ $comments_topic = new BlogCommentsTopic(); $comments_topic->set_id_in_module($post->get_id()); $comments_topic->set_url(BlogUrlBuilder::display_comments_posts($post->get_slug())); $this->view->put_all(array( 'ID' => $post->get_id(), 'NAME' => $post->get_name(), 'SLUG' => $post->get_slug(), 'CONTENT' => FormatingHelper::second_parse($post->get_content()), 'CREATED' => date('d/m/Y', $post->get_created()), 'APPROVED' => $post->get_approved(), 'USER' => $result['login'], 'LINK_USER_PROFILE' => UserUrlBuilder::profile($result['user_id'])->absolute(), 'USER_ID' => $result['user_id'], 'USER_LEVEL_CLASS' => UserService::get_level_class($result['level']), 'COMMENTS' => $comments_topic->display() )); $this->post_name = $post->get_name(); return $this->generate_response(); } private function init() { $this->lang = LangLoader::get('common', 'blog'); $this->view = new FileTemplate('blog/BlogPostController.tpl'); $this->view->add_lang($this->lang); } private function get_blog(){ $this->blog = BlogService::get_blog($this->blog_post); return $this->blog; } private function generate_response() { $response = new SiteDisplayResponse($this->view); $graphical_environment = $response->get_graphical_environment(); $graphical_environment->set_page_title($this->lang['module_title']); $breadcrumb = $graphical_environment->get_breadcrumb(); $breadcrumb->add($this->lang['module_title'], BlogUrlBuilder::home()->rel()); $breadcrumb->add($this->blog_name); $breadcrumb->add($this->post_name); return $response; } }
et le tpl qui va avec:
Code HTML :
<section> <header> <h1>{NAME}</h1> <div class="more"> ${LangLoader::get_message('by', 'common')} <a href="{LINK_USER_PROFILE}" class="{USER_LEVEL_CLASS}" # IF C_USER_GROUP_COLOR # style="color:{USER_GROUP_COLOR}" # ENDIF #>{USER} </a> ${LangLoader::get_message('the', 'common')} {CREATED} </div> </header> <article> <p>{CONTENT}</p> </article> <footer></footer> </section> <section> <header> <h1>Commentaires</h1> <div class="more"></div> # INCLUDE COMMENTS # </header> </section>
MrToine Membre non connecté
Booster Bazooka
- Booster Bazooka
- Voir le profil du membre MrToine
- Inscrit le : 26/10/2014
- Groupes :
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie