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

User avatar
axew3
w3all User
w3all User
Posts: 2888
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

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

Post by axew3 »

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%).

Since 2.8.8 add the param
info_right_or_bottom

possible values: bottom or right
if omitted by default will display file's info on bottom of the image
or use like this to display file's info on the right

Code: Select all

info_right_or_bottom="right"
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

<table><tbody>
<tr><td>...</td> <td>spacer</td> <td>...</td></tr>
<tr><td>...</td> <td>spacer</td> <td>...</td></tr>
etc ...
</tbody></table>
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
views/phpbb_last_topics_withimage_output_shortcode.php


This shortcode not implement avatars (so phpbb_last_topics_withimage_output_shortcode.php is more easy to be edited for own use).
While option
Retrieve posts on Last Topics Widget based on phpBB user's permissions
affect, if active option into WP_w3all plugin admin config page.
To edit the output and style the shortcode output, see file:
views/phpbb_last_topics_withimage_output_shortcode.php

NOTE: like others shortcodes files that reside into the plugin views folder or the other possible customizable files, 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
/wp-content/plugins/wp-w3all-custom
so custom modifications done into these files, aren't overwritten when plugin update.
User avatar
axew3
w3all User
w3all User
Posts: 2888
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

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

Post by axew3 »

A simple and basic working example result to view is here:
phpBB grid list in WordPress: latest topics with images attachments
GamingSanctum

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

Post by GamingSanctum »

Hello!
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?
GamingSanctum
Posts: 3
Joined: Wed Jun 30, 2021 1:54 am

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

Post by GamingSanctum »

Sorry, I just realized that the attachments did not go through. See attachment included here.
Attachments
Capture.PNG
Capture.PNG (23.66 KiB) Viewed 19576 times
User avatar
axew3
w3all User
w3all User
Posts: 2888
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

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

Post by axew3 »

Missed this...
The error json is given where there are not enough posts with images to be retrieved based on how much you instead require to be on the shortcode!
User avatar
axew3
w3all User
w3all User
Posts: 2888
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

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

Post by axew3 »

This shortcode has been fixed/reviewed on 2.8.8 version
Post Reply