affichage du nom de cat et auteur [Réglé]
janus57 Membre non connecté
-
Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
-
Equipe Assistance
Reprise du message précédent
Bonsoir,et l'erreur fournit pas le debug ?
Edit: avec ceci cela fonctionne ?
Code PHP :
$row = PersistenceContext::get_querier()->select(PREFIX.'news', array('id', 'title', 'contents', 'timestamp'), 'WHERE visible = 1 ORDER BY timestamp DESC LIMIT 0,6 ');
Cordialement, janus57
Édité par janus57 Le 25/06/2013 à 00h21
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
multiple rows have been found but the query expect only one result
-> SELECT id, title, contents, timestamp FROM phpboost_news WHERE visible = 1 ORDER BY timestamp DESC LIMIT 0,2
array (
)
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
janus57 Membre non connecté
-
Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
-
Equipe Assistance
avec ceci :
Code PHP :
$row = PersistenceContext::get_querier()->select(PREFIX.'news', array('id', 'title', 'contents', 'timestamp'), 'WHERE visible = 1 ORDER BY timestamp DESC LIMIT 0,1');
Sinon faut essayer avec le code de ElenWii, déjà que je ne suis pas très fort en SQL, mais en plus avec les fonctions de PHPBoost, c'est pas trop mon domaine d'action.
Cordialement, janus57
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
Connais-tu un développeur qui y arriverai ?
janus57 Membre non connecté
-
Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
-
Equipe Assistance
samghami :
Non je suis désolé cale ne fonctionne pas. Merci quand même pour ton aide.
Connais-tu un développeur qui y arriverai ?
Connais-tu un développeur qui y arriverai ?
Bonsoir,
ici même
sinon dernière essaie (pour ce soir car là j'en peu plus) :
1 :
Code PHP :
$row = PersistenceContext::get_querier()->select(PREFIX.'news', array('id', 'title', 'contents', 'timestamp'),'ORDER BY timestamp DESC LIMIT 0,1 ');
2 :
Code PHP :
$row = PersistenceContext::get_querier()->select(PREFIX.'news', array('id', 'title', 'contents', 'timestamp'),'ORDER BY timestamp DESC LIMIT 0,6 ');
Edit : version 3 :
Code PHP :
[code=php]$row = PersistenceContext::get_querier()->select(PREFIX.'news', array('id', 'title', 'contents', 'timestamp'));[/code]
Edit2 : oublie tout ça j'ai compris mon erreur
Cordialement, janus57
Édité par janus57 Le 25/06/2013 à 01h06
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
janus57 Membre non connecté
-
Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
-
Equipe Assistance
derniers codes pour cette nuit :
Code PHP :
$row = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp FROM ' . DB_TABLE_NEWS . ' WHERE visible = 1 ORDER BY timestamp DESC LIMIT 0,6 ');
OU
Code PHP :
$row = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp FROM ' . DB_TABLE_NEWS . ' WHERE visible = 1 ORDER BY timestamp DESC LIMIT 6 ');
Cordialement, janus57
Édité par janus57 Le 25/06/2013 à 01h22
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
janus57 Membre non connecté
-
Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
-
Equipe Assistance
vraiment les derniers codes pour cette nuit :
Code PHP :
$row = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp FROM PREFIX.'news' WHERE visible = 1 ORDER BY timestamp DESC LIMIT 0,6 ');
OU
Code PHP :
$row = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp FROM PREFIX.'news' WHERE visible = 1 ORDER BY timestamp DESC LIMIT 6 ');
Mais sinon c'est vraiment pas loin, donc test par toi même, mais normalement cela devrait retourner des résultats si la syntaxe est bonne.
Après si ça sort pas les bonne données bah c'est juste que je sélectionne l'ID qui n'est relié à rien, au passage l'id est même pas affiché au niveau du tpl...
Cordialement, janus57
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
Ils n'affichent aucune erreur mais il n'affiche pus non plus le contenue de la page
janus57 Membre non connecté
-
Booster Fusée
- Voir le profil du membre janus57
- Inscrit le : 07/12/2007
- Groupes :
-
Equipe Assistance
envoie le contenu de ton fichier home.tpl
+ dans le fichier php ajoute : var_dump($row);
et remplace
Code :
par PREFIX.'news'Code :
si y a toujours une page blanche ou juste une ligne après avoir ajouté le var_dump($row);' . PREFIX . 'newsCordialement, janus57
Édité par janus57 Le 25/06/2013 à 02h17
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
Code TPL :
Pour le reste je n'est pas compris
j1.seth Membre non connecté
-
Administrateur
- Voir le profil du membre j1.seth
- Inscrit le : 01/09/2008
- Site internet
- Groupes :
-
Chef de Projet
-
Equipe Développement
En effet Janus tu n'étais pas loin

La requête est bien celle là :
Code PHP :
$result = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp FROM ' . PREFIX . 'news WHERE visible = 1 ORDER BY timestamp DESC LIMIT 6 ');
Ensuite pour afficher le contenu des champs il faut parcourir les résultats :
Code PHP :
while ($row = $result->fetch()) { echo 'ID : ' . $row['id']; }
Bien sûr il ne faut pas afficher les variables directement avec un echo, il faut passer par le TPL, mais l'idée est là
Édité par j1.seth Le 25/06/2013 à 11h57
samghami Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre samghami
- Inscrit le : 16/04/2012
- Site internet
Code PHP :
<?php /*################################################## * HomeCustomHomePageExtensionPoint.class.php * ------------------- * begin : August 25, 2012 * copyright : (C) 2012 Kevin MASSY * email : kevin.massy@phpboost.com * * ################################################### * * 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 HomeCustomHomePageExtensionPoint implements HomePageExtensionPoint { public function get_home_page() { return new DefaultHomePage($this->get_title(), $this->get_view()); } private function get_title() { return LangLoader::get_message('title', 'common', 'HomeCustom'); } private function get_view() { $template = new FileTemplate('HomeCustom/home.tpl'); $this->build_view($template); return $template; } private function build_view(View $template) { $result = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp FROM ' . PREFIX . 'news WHERE visible = 1 ORDER BY timestamp DESC LIMIT 6 '); while ($row = $result->fetch()) { echo 'ID' : $row['id']; } 'U_LINK' => Url::to_absolute('/news/news.php?id=' . $row['id']), 'TITLE' => $row['title'], 'CONTENT' => $row['contents'], 'DATE' => $date->format(DATE_FORMAT_TEXT_LONG) )); } } ?>
Home.tpl:
j1.seth Membre non connecté
-
Administrateur
- Voir le profil du membre j1.seth
- Inscrit le : 01/09/2008
- Site internet
- Groupes :
-
Chef de Projet
-
Equipe Développement
Essayes ça
:Code PHP :
<?php /*################################################## * HomeCustomHomePageExtensionPoint.class.php * ------------------- * begin : August 25, 2012 * copyright : (C) 2012 Kevin MASSY * email : kevin.massy@phpboost.com * * ################################################### * * 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 HomeCustomHomePageExtensionPoint implements HomePageExtensionPoint { public function get_home_page() { return new DefaultHomePage($this->get_title(), $this->get_view()); } private function get_title() { return LangLoader::get_message('title', 'common', 'HomeCustom'); } private function get_view() { $template = new FileTemplate('HomeCustom/home.tpl'); return $this->build_view($template); } private function build_view(View $template) { $result = PersistenceContext::get_querier()->select(' SELECT id, title, contents, timestamp FROM ' . PREFIX . 'news WHERE visible = 1 ORDER BY timestamp DESC LIMIT 6 '); while ($row = $result->fetch()) { $date = new Date(DATE_TIMESTAMP, TIMEZONE_AUTO, $row['timestamp']); $template->assign_block_vars('news', array( 'U_LINK' => Url::to_absolute('/news/news.php?id=' . $row['id']), 'TITLE' => $row['title'], 'CONTENT' => $row['contents'], 'DATE' => $date->format(DATE_FORMAT_TEXT_LONG) )); } return $template; } } ?>
Et :
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie