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

WP_w3all phpBB code with others external plugins
User avatar
axew3
w3all User
w3all User
Posts: 1875
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 »

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:
class.wp.w3all-phpbb.php
and replace it in
/wordpress/wp-content/plugins/wp-w3all-phpbb-integration/

wp_w3all.php
and replace it in
/wordpress/wp-content/plugins/wp-w3all-phpbb-integration/

and file
phpbb_last_topics_withimage_output_shortcode.php
add it into folder:
/wordpress/wp-content/plugins/wp-w3all-phpbb-integration/views/

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

<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 options
Retrieve posts on Last Topics Widget based on phpBB user's permissions
and
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:
views/phpbb_last_topics_withimage_output_shortcode.php

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
/wp-content/plugins/wp-w3all-config
so custom modifications done into these files, aren't overwritten when plugin update.

User avatar
axew3
w3all User
w3all User
Posts: 1875
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

Post Reply