(06-07-2020 03:46 AM)RateU Wrote: (06-07-2020 02:07 AM)Verilog Wrote: I managed to get it to work.
Great! You now can display XThreads data wherever you want
Don't forget to cache the templates to reduce the query
I used global hook and templates to do caching of templates.
(06-07-2020 03:46 AM)RateU Wrote: (06-07-2020 02:07 AM)Verilog Wrote: Now I wanted to know if I had two different XThreads based forums and I wanted both of them on the portal in separate sections. One option is to copy the below code and replicate it with replacing templates but that feels loading extra SQL query again. Is there a way I can get different templates so that I can display them in their own style on the portal?
Well, technically, you can load the threads from different forums using WHERE t.fid IN (10,11) and load the $threadfield_cache not for a specific forum only.
The problem is, there is no guarantee threads from both forums will be displayed, because it depends on the ORDER BY and the LIMIT.
For example:
ORDER BY t.lastpost DESC
Threads from forum ID 10 and 11:
1. Threads from FID 10 - lastpost time 200
2. Threads from FID 10 - lastpost time 199
3. Threads from FID 11 - lastpost time 198
4. Threads from FID 11 - lastpost time 197
You want to load 2 threads from each forums, so you put 2 in the LIMIT of the query. But only 1st and 2nd threads will be displayed, not all of them, even though your intent is to load 2 threads from each forum (2 threads from forum ID 10 and 2 threads from forum ID 11 in separate templates).
Since I wanted to use a different template for both of them, I thought about using fid using template conditional plugin to separate the content in templates. For example, I load both threads from id 10 and 11 and use different templates for their style.
Do you think that would be a good choice and solve this without using duplicate extra queries?