MyBB Community Forums

Full Version: PHP code for HTML Description
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I added Open Graph meta tags to the headerinclude template, but I want to dynamically populate them using the description of each page, so what is the PHP tag/Hook that generates the meta description for the forum pages?
instead of adding the code to headerinclude template,
you can add to individual templates after {$headerinclude} & before </head>

basically you can add the code in below templates
index, portal, forumdisplay, showthread, calendar ..
(2017-12-28, 02:36 AM).m. Wrote: [ -> ]instead of adding the code to headerinclude template,
you can add to individual templates after {$headerinclude} & before </head>

basically you can add the code in below templates
index, portal, forumdisplay, showthread, calendar ..

I understand what you are saying.

What I want is each thread's open graph metadata to be relevant to the topic if that makes sense.
@Noobly, how are you going to populate it for each thread? Who is going to write each thread's description?

You can modify the showthread template to include variables after $headerinclude, then have a plugin register a function on the showthread_start hook (I'd have to look at the code to verify this hook's real name) to populate that variable.
(2017-12-28, 07:14 PM)laie_techie Wrote: [ -> ]@Noobly, how are you going to populate it for each thread? Who is going to write each thread's description?

You can modify the showthread template to include variables after $headerinclude, then have a plugin register a function on the showthread_start hook (I'd have to look at the code to verify this hook's real name) to populate that variable.

I assumed the default behavior for myBB would be to use the first 100 chars of the OP as the description, if that is not the case then it must be added to the development board as it's a critical aspect of SEO and must be native behavior.
Bump for help
(2017-12-30, 12:15 PM)Noobly Wrote: [ -> ]use the first 100 chars of the OP as the description

By default, we don't have it.

Workaround possibility:
1. Install Thread Tooltip Preview.
2. You can use {$thread['postpreview']} in your showthread template as description.
(2018-03-05, 06:27 PM)RateU Wrote: [ -> ]
(2017-12-30, 12:15 PM)Noobly Wrote: [ -> ]use the first 100 chars of the OP as the description

By default, we don't have it.

Workaround possibility:
1. Install Thread Tooltip Preview.
2. You can use {$thread['postpreview']} in your showthread template as description.

Thank you for the reply and workaround. 

3 Questions:

1. Will MyBB 2 support open graph etc out of the box (that is why I want this "hook"), I am manually adding the meta tags.

2a. This plugin you mentioned, what other behavior does it introduce?
2b. I do not want any modifications to my theme by the plugin, so if I can hook {$thread['postpreview']} without it adding that preview functionality elsewhere it would be perfect for now. (running Modern by some Taiwan guy who is no longer around.) 

3. Does this affect performance, I understand to render {$thread['postpreview']} it would require additional database queries, are those noticeable or should it not have a visible impact on performance?
(2018-03-06, 06:39 AM)Noobly Wrote: [ -> ]1. Will MyBB 2 support open graph etc out of the box (that is why I want this "hook"), I am manually adding the meta tags.
Better to ask it to MyBB's dev

(2018-03-06, 06:39 AM)Noobly Wrote: [ -> ]2a. This plugin you mentioned, what other behavior does it introduce?
Originally, the purpose of the plugin is for displaying tooltips in forumdisplay.

(2018-03-06, 06:39 AM)Noobly Wrote: [ -> ]2b. I do not want any modifications to my theme by the plugin, so if I can hook {$thread['postpreview']} without it adding that preview functionality elsewhere it would be perfect for now. (running Modern by some Taiwan guy who is no longer around.)
The plugin itself doesn't modify any template (there is no find_replace_templatesets function run by the plugin).
Since the basic purpose of the plugin is for displaying tooltips in forumdisplay, maybe (depends on your theme) the "description" will be displayed on the page. If you really want to prevent it, you can "disable" line #15 and #16 of the plugin.

(2018-03-06, 06:39 AM)Noobly Wrote: [ -> ]3. Does this affect performance
Unfortunately, every plugins you add to your forum will affect performance.

(2018-03-06, 06:39 AM)Noobly Wrote: [ -> ]I understand to render {$thread['postpreview']} it would require additional database queries, are those noticeable or should it not have a visible impact on performance?
The plugin creates the preview when the user submit the thread. It is saved in your threads table. So it doesn't require additional database query when displaying it.

Alternatively, if your forum is new, you can install plugin for thread description, so your user will be forced to fill the description manually before submitting the thread. There are some methods for this. But you can search it in the Mods section:
https://community.mybb.com/mods.php?acti...ry=plugins