Page 1 of 1

Shortcode: display phpBB last topics grid in Wordpress with first topic's attached image

Posted: Tue May 29, 2018 7:54 am
by axew3
As on 1.8.9 version just patched at date of this post, a new shortcode w3allastopicswithimage added to display
Last Updated Topics into a grid.
Basic example: phpBB grid list in WordPress: latest topics with images attachments
If you wish to update and use this before 1.9.0 release (or you have download/install the plugin, before the date of this post)
download these three files:
and replace it in

and replace it in

and file
add it into folder:

How it work
Suppose there are forums with ID-5 and ID-9, that are sub-forums and belongs to the Forum Category with ID-1.
Then will be retrieved all latest updated topics from forums with ID-5 and ID-9, that will contain ALMOST one attachment into any of their posts. ONLY the first inserted attachment will be retrieved to be used and will display for the post/topic into the WordPress w3allastopicswithimage shortcode.
The shortcode to use is like this:

Code: Select all

[w3allastopicswithimage cat_id="1" topics_number="6" post_text="1" text_words="30" columns_number="2" gap_columns="5"]
and will produce this result:
Retrieve all latest topics from sub forums which belongs to the specified Forum Cat with ID 1
Retrieve last 6 updated topics/posts
With post text
With 30 words
In two columns
With gap space between columns of 5 (after calculated in %)

or without post text

Code: Select all

[w3allastopicswithimage cat_id="1" topics_number="6" columns_number="2" gap_columns="10"]
The columns_number param is useful to show more columns per row, minimum 2. If omitted, 2 by default.
The gap_columns param is an int value that is calculated after in %, if omitted the value will be 0 (0%).

the topic need to have almost an attachment or will not be retrieved: the query search for all latest updated topics WITH ALMOST ONE ATTACHMENT ON HIS POSTS. Only the first attachment added into the topic will be retrieved to be used as image to display into the WP shortcode output. The attach can be added into any post, BUT ONLY THE ONE THAT WILL RESULT AS THE FIRST ONE ATTACHED (based on related attachments time value) will be retrieved to display. That so, could be inserted into any of topic's posts and not only into the first.

the query will return any kind of attach that is the first (time based) inserted on topic. If the first attach that belong to the topic isn't an image, then the link to download the file will display.

This is a raw version that show how to achieve the result, but could be coded in several different ways, especially about the output. The output grid is done by using an html table that look like this if two columns:

Code: Select all

<tr><td>...</td> <td>spacer</td> <td>...</td></tr>
<tr><td>...</td> <td>spacer</td> <td>...</td></tr>
etc ...
three columns will be:

Code: Select all

<tr><td>...</td> <td>spacer</td> <td>...</td> <td>spacer</td>  <td>...</td></tr>
and so on ...
READ inline hints on file

This shortcode not implement avatars (so phpbb_last_topics_withimage_output_shortcode.php is more easy to be edited for own use).
While options
Retrieve posts on Last Topics Widget based on phpBB user's permissions
Last Topics links for embedded phpBB iframe into WordPress
are implemented and take effect on results, if active options into WP_w3all plugin admin config page.
To edit the output and style the shortcode output, see file:

NOTE: like others shortcodes files that reside into plugin's views folder, you can activate the option
Use custom files to display Last Topics Widgets, Login Widget or Last Topics Shortcode content
in WP_w3all admin config page and copy/paste this file into the custom folder
so custom modifications done into these files, aren't overwritten when plugin update.

example of shortcode that display phpBB last topics grid in Wordpress with first topic's attached image

Posted: Wed May 30, 2018 8:56 am
by axew3
A simple and basic working example result to view is here:
phpBB grid list in WordPress: latest topics with images attachments

Re: Shortcode: display phpBB last topics grid in Wordpress with first topic's attached image

Posted: Wed Jun 30, 2021 1:51 am
by GamingSanctum
I have installed this plugin and the logins appears to be working great! Now, I'm trying to use this last topic with images shortcode, but when I try to update my page I get the following error message:
"Updating Failed. The response in not a valid JSON response."

(see attached image)
Am I entering the shortcode incorrectly?