Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not Solved [How To?] PHP code for HTML Description
#1
Not Solved
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?
Reply
#2
Not Solved
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 ..
Reply
#3
Not Solved
(12-28-2017, 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.
Reply
#4
Not Solved
@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.
Reply
#5
Not Solved
(12-28-2017, 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.
Reply
#6
Not Solved
Bump for help
Reply
#7
Not Solved
(12-30-2017, 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.
XThreads App For MyBB: Link Directory, YouTube Gallery & etc - Full List
My Demo Site
Reply
#8
Not Solved
(03-05-2018, 06:27 PM)RateU Wrote:
(12-30-2017, 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?
Reply
#9
Not Solved
(03-06-2018, 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

(03-06-2018, 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.

(03-06-2018, 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.

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

(03-06-2018, 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
XThreads App For MyBB: Link Directory, YouTube Gallery & etc - Full List
My Demo Site
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)