FAQ template

More
13 years 1 month ago #32262 by Pitou
FAQ template was created by Pitou
Bonjour tout le monde.

J'essaye d'arranger le template FAQ.
Actuellement, il permet d'afficher les catégories et les subcatégories.
J'aimerais qu'il puisse m'affiche la catégorie courante, ainsi que les autres catégories (sub ou de même niveau), des articles que la catégorie contient.

Dans categorie_items.php, je vois bien à peu près à quel endroit on doit modifier le code, mais je n'arrive pas à trouver comment faire une sélection des catégories de même niveau.
Il faudrait que $sub_cats contienne aussi les catégories de même niveau pour les articles présents dans la catégorie.

J'ai peut-être tout faux..
Avez-vous une idée ?
Merci.

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #32265 by ggppdk
Replied by ggppdk on topic FAQ template
FAQ template is meant to be used with 1st-sublevel sub-categories, although it will display (flat) all other subcategories too.

Of course you can manipulate the categories to examine their parents and create a different organization, i cannot say how much time it will take, because custom development is not always easy to calculate time required, depends on skill/knowledge of you or your programmer.

In order to do what you need you can use a global array called $globalcats:
Code:
global $globalcats; echo "<pre>"; print_r($globalcats); echo "</pre>";

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
13 years 1 month ago #32310 by Pitou
Replied by Pitou on topic FAQ template
Merci pour ta réponse, je vais voir ce que je peux en tirer.
++
Et bonne année !

Please Log in or Create an account to join the conversation.

More
13 years 3 weeks ago #32567 by Pitou
Replied by Pitou on topic FAQ template
Ok, bon, je suis perdu, j'ai besoin d'aide. Ca fait longtemps que j'ai plus fait de php et là, pour s'y remettre, c'est un peu chaud.

J'ai regardé dans globalcats, mais je ne pense pas que cela m'aide beaucoup. Globalcats propose la liste complète des catégories. Ce n'est pas ça que je recherche.

J'ai regardé dans le code plus haut dans category_items.php.
Code:
if ($this->items) : $currcatid = $this->category->id; $cat_items[$currcatid] = array(); $sub_cats[$currcatid] = & $this->category; foreach ($this->categories as $subindex => $sub) : $cat_items[$sub->id] = array(); $sub_cats[$sub->id] = & $this->categories[$subindex]; endforeach;

La ligne "foreach ($this->categories as $subindex => $sub):" propose les sous-catégories relatives à la catégorie principale.
Moi je voudrais à la place les catégories relatives à l'article, afin de faire le tri selon ces catégories là.
Du coup, j'ai fait ça :
Code:
if ($this->items) : $currcatid = $this->category->id; $cat_items[$currcatid] = array(); $sub_cats[$currcatid] = & $this->category; $items = & $this->items; for ($i=0; $i<count($items); $i++) : foreach ($items[$i]->cats as $relatcats => $sub) : $cat_items[$sub->id] = array(); $sub_cats[$sub->id] = & $items[$i]->cats[$relatcats]; endforeach; foreach ($items[$i]->cats as $cat) : if (isset($cat_items[$cat->id])) : $cat_items[$cat->id][] = & $items[$i]; endif; endforeach; endfor;


Le résultat est presque celui attendu : j'ai bien chaque catégorie relative aux articles présents dans la catégorie principale. Le problème, c'est qu'il me faut maintenant compter le nombre d'articles présents dans la page et présents dans la catégorie relative. Et là, ça ne marche pas. seul le premier article de la catégorie est présent, les autres sont invisibles.

(J'ai désactivé dans un premier temps l'affichage du décompte des articles présents dans la catégorie qui renvoient des erreurs, car les données sont absentes de $sub)

j'imagine qu'il faut maintenant que je modifie ici :
Code:
foreach ($cat_items as $catid => $items) : $sub = & $sub_cats[$catid]; if (count($items)==0) continue; if ($catid!=$currcatid) $count_cat++;
mais je ne trouve pas la solution.

Quelqu'un peut-il m'aider ?
Un grand merci.

Please Log in or Create an account to join the conversation.

More
13 years 3 weeks ago #32569 by ggppdk
Replied by ggppdk on topic FAQ template
I am not sure out of translation what you are trying to do, but maybe you will need help from a PHP programmer, if you describe in English what you want to achieve, maybe i can answer you

Also, current FAQ template structure does it not serve your need?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
13 years 3 weeks ago #32616 by Pitou
Replied by Pitou on topic FAQ template
Hello, thx for your help. I'll try in english.

Currently, this faq template doesn't serve my needs.
this template show only sub cats.
What I want is to show all the cats (not only subcats) the items is linked with.

I've a lot of categories at the same level, and sometimes subcategories.
When I write an article, I'll link it with one, two or more categories, sometimes with subcategories.

With this code (maybe there's a better way to code it),
Code:
if ($this->items) : $currcatid = $this->category->id; $cat_items[$currcatid] = array(); $sub_cats[$currcatid] = & $this->category; $items = & $this->items; for ($i=0; $i<count($items); $i++) : foreach ($items[$i]->cats as $relatcats => $sub) : $cat_items[$sub->id] = array(); $sub_cats[$sub->id] = & $items[$i]->cats[$relatcats]; endforeach; foreach ($items[$i]->cats as $cat) : if (isset($cat_items[$cat->id])) : $cat_items[$cat->id][] = & $items[$i]; endif; endforeach; endfor;
I achieved to show all the categories the article is link with, but actually, it show only the first article, not the others. Sometime, the same article is shown 2 or 3 times, because he's linked with 2 or 3 categories.

So I've got :
categorie 1
--- article A

categorie 2
-- article B

categorie 3
-- article A
-- and if there is an other article linked with this categorie, I want it there.. for exemple article C. Actually, there just the first article.

If you try it on your faq template, you might show the same result.

Now, I'm trying to find the way to display under the categorie all the items linked with "$currcatid" and $relatcats.

I hope you've understood my needs and I apologize for my english. Thanks for the help.

Please Log in or Create an account to join the conversation.

More
13 years 3 weeks ago #32618 by ggppdk
Replied by ggppdk on topic FAQ template
First,
categories of your items that are outside current category subtree have NOT been retrieved !!

Second,
your code keeps reseting subcategory items and keeps adding only last one to be added

Try replacing, in original template code:
Code:
$items = & $this->items; for ($i=0; $i<count($items); $i++) : foreach ($items[$i]->cats as $cat) : if (isset($cat_items[$cat->id])) : $cat_items[$cat->id][] = & $items[$i]; endif; endforeach; endfor;
with:
Code:
$items = & $this->items; $need_query_cats = array(); for ($i=0; $i<count($items); $i++) : foreach ($items[$i]->cats as $cat) : if ( !isset($cat_items[$cat->id]) ) : $need_query_cats[] = $cat->id; endif; $cat_items[$cat->id][] = & $items[$i]; endforeach; endfor; $db = JFactory::getDBO(); $query = 'SELECT c.*,' . ' CASE WHEN CHAR_LENGTH( c.alias ) THEN CONCAT_WS( \':\', c.id, c.alias ) ELSE c.id END AS slug' . ' FROM #__categories AS c' . ' WHERE c.id IN ('.implode(",",$need_query_cats).')'; ; $db->setQuery($query); $extra_cats = $db->loadObjectList('id');

and
Code:
<?php global $globalcats; $count_cat = -1; foreach ($cat_items as $catid => $items) : $sub = & $sub_cats[$catid];
with:
Code:
<?php global $globalcats; $count_cat = -1; foreach ($cat_items as $catid => $items) : if ( isset($sub_cats[$catid]) ) $sub = & $sub_cats[$catid]; else $sub = & $extra_cats[$catid];

NOTE: i have not tested this

Regards


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
13 years 3 weeks ago #32629 by Pitou
Replied by Pitou on topic FAQ template
YEAH !
Without any test ?
It seems to works perfectly !
Many thanks for this and for all your work !

++

Please Log in or Create an account to join the conversation.

More
13 years 3 weeks ago #32667 by micker
Replied by micker on topic FAQ template
tu nous tien au courant si ca marche ?

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
13 years 3 weeks ago #32672 by Pitou
Replied by Pitou on topic FAQ template
Salut

Ca marche et c'est génial. A mon humble avis, c'est vraiment un truc à implémenter dans les templates par défaut : la capacité de pouvoir afficher ainsi pour une catégorie principale, par groupe de catégories, l'ensemble des articles liés à la fois à la catégorie principale et à d'autres catégories en dehors de la catégorie principale.

Il y avait des redondances de catégories (par exemple, si tu lis un article à la catégorie principale, puis à d'autres catégories, il est d'abord repris sur la catégorie principale, puis ensuite on reprend l'ensemble des catégories qui sont liées). Donc au niveau de l'affichage, tout d'abord l'ensemble des articles de la catégorie principale, puis toutes les catégories liées.
j'ai ajouté deux lignes de codes pour supprimer le cas de la catégorie principale, puis pour ne pas reprendre en temps que catégories les articles présents dans la page d'accueil.
J'ai mis en "dur" le numéro id de la page d'accueil. Je ne sais pas s'il existe une variable globale pour définir l'id de la catégorie page d'accueil, mais comme le nom de la catégorie va changer en fonction de chaque personne, créer une regex pour trouver un nom dont on n'est pas sûr...
Bref, je l'ai mis en dur.
Sûrement que GGPPDK a une astuce pour trouver cela facilement.
Bref, ci-joint le fichier faq en question, avec les modifications et une capture de l'affichage, sur une seule colonne (marche aussi bien avec 2 colonnes).

And yet in english :
It's works great. I think it would be a good feature for the futures officials templates.

There where redundancy categories (for example : the first main categorie displayed all the articles, and after they were displayed with others categories. I mean it's not usefull to display this articles grouped together). I've made also a categorie for the homepage and I didn't want them to be displayed in my page.
So I added two lignes to ggppdk code, but I had to write the homepage categorie's id, cause I dont know if there was a variable for this. (And the Regex would works only if the homepage categorie were different from mine).

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save