FAQ template

More
11 years 3 months 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
11 years 2 months 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...

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

More
11 years 2 months 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
11 years 2 months 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
11 years 2 months 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...

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

More
11 years 2 months 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.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.287 seconds
Save
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