View Full Version : Twitter Card Feature!
ku-med
08-01-2015, 01:20 PM
Hello!
I want to ask how to setup this cool feature of twitter to my vbulletin forum
https://dev.twitter.com/cards/types/summary
I don't know where to post that code?
Any ideas how to make that work in vbulletin?
Thanks in advance! :)
I added it to the top bit of the headinclude template bellow all the other meta stuff.
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@yourtwitteraccountname" />
<meta name="twitter:description" content="{vb:raw vboptions.description}" />
<meta name="twitter:title" content="your site title" />
ku-med
08-01-2015, 02:52 PM
Thanks mate : ) : ) : )
Edit:
Hmm will the twitter card content display the text of each topic when i post the url in twitter ? or it will just display my site description by using this code {vb:raw vboptions.description} ?
ku-med
08-04-2015, 06:21 PM
Whenever someone post a link of any thread in the forums, I'd like to see in the twitter card: Title of thread plus the first lines text of that thread. So I've tried to put this code in the SHOWTHREAD but it didn't work tho .. :( Any ideas how to make that work? Like in this pic ignoring the image thumbnail.
https://vborg.vbsupport.ru/external/2015/08/28.jpg
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@mytwitteraccount" />
<meta name="twitter:description" content="{vb:raw thread.meta_description}" />
<meta name="twitter:title" content="{vb:raw thread.prefix_plain_html} {vb:raw thread.title}" />
--------- Edit ------------
Finally it's worked
I had to add these two codes in the showthread template at the end before </html> :)
<meta name="twitter:description" content="{vb:raw thread.meta_description}" />
<meta name="twitter:title" content="{vb:raw thread.prefix_plain_html} {vb:raw thread.title}" />
VICOS
11-23-2015, 03:10 AM
You could actually put
<meta name="twitter:description" content="{vb:raw thread.meta_description}" />
<meta name="twitter:title" content="{vb:raw thread.prefix_plain_html} {vb:raw thread.title}" />
in the SHOWTHREAD template right under <title></title>, then they would be inside of the <head></head> where technically they belong.
Then, I changed headinclude to look like this:
<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content="@twitteruser" />
<meta name="twitter:site" content="@twitteruser" />
<meta name="twitter:image" content="http://images.com/twitter-02.png" />
<vb:if condition="$show['threadinfo']">
<!-- Twitter title, description set in template SHOWTHREAD -->
<vb:elseif condition="$show['foruminfo']" />
<meta name="twitter:title" content="{vb:raw foruminfo.title_clean} - {vb:raw vboptions.bbtitle}" />
<meta name="twitter:description" content="{vb:raw foruminfo.description_clean}" />
<meta name="keywords" content="{vb:raw foruminfo.title_clean}, {vb:raw vboptions.keywords}" />
<meta name="description" content="<vb:if condition="$pagenumber > 1">{vb:rawphrase page_x, {vb:raw pagenumber}}-</vb:if>{vb:raw foruminfo.description_clean}" />
<vb:else />
<meta name="twitter:title" content="{vb:raw vboptions.bbtitle}" />
<meta name="twitter:description" content="{vb:raw vboptions.description}" />
<meta name="keywords" content="{vb:raw vboptions.keywords}" />
<meta name="description" content="{vb:raw vboptions.description}" />
</vb:if>
Just look for the following line in headinclude as the place to sync up.
<vb:if condition="$show['threadinfo']">
and then add the Twitter stuff in where it belongs among the existing code as shown above. You have to go through all of this because the Thread Title and Meta Description are not available as variables in the headinclude template.
This way, you will get a Twitter card that makes sense for each of the following type of pages: 1) A forum page, 2) a Thread , 3) any other page. Hope this helps.
PedroMA
03-15-2016, 12:14 PM
I'm searching about that the "twitter:image" charge automatically the first image attach. Any idea?
--------------- Added 15 Mar 2016 at 14:22 ---------------
I'm trying with
<meta name="twitter:image" content="http://url.com/attachment.php?attachmentid={vb:raw attachmentid}&d={vb:raw attachmentinfo.dateline}">
but doesn't work.
VICOS
03-15-2016, 02:00 PM
That's the way most people would probably like it to work, but, if I remember correctly, this is not easily accomplished within the framework of vB v4. You would probably have to write/mod PHP code to make this happen. I imagine that there is a table with a 1-MANY relationship which maps the postID to attachments. References to attachments are probably only available in the section of code which loops thru all of the posts in a thread and displays them.
So, you would have to find the first post in a thread and then query the attached images, select the first one and make this data available in the section of code which processes the <head></head> section of the output.
According to the twittercard dev page (https://dev.twitter.com/cards/getting-started#opengraph) if the tag isn't present then it will fall back and look for opengraph properties, so you should be able to leave out the twitter:image tag and let the following mod put the opengraph ones in.
https://vborg.vbsupport.ru/showthread.php?p=2434215
PedroMA
03-15-2016, 08:23 PM
According to the twittercard dev page (https://dev.twitter.com/cards/getting-started#opengraph) if the tag isn't present then it will fall back and look for opengraph properties, so you should be able to leave out the twitter:image tag and let the following mod put the opengraph ones in.
https://vborg.vbsupport.ru/showthread.php?p=2434215
No, In my case without image meta doesn't charge anything. I need this for CMS, and I'm triying to insert the meta tags inside the headinclude or inside vbcms_content_article_page. The problems is that in headinclude or vbcms_content_article_page I can't catch attachments variable information.
Thanks for the reply. More ideas?
Regards.
PedroMA
10-30-2016, 10:23 PM
I need to solve the issue. Something from vbulletin support staff can help me?
Elixar
10-31-2016, 02:59 AM
I need to solve the issue. Something from vbulletin support staff can help me?
This is the place to get support for stuff like this, and members of the community primarily help so it's done primarily by volunteers. ;)
PedroMA
10-31-2016, 10:54 AM
This is the place to get support for stuff like this, and members of the community primarily help so it's done primarily by volunteers. ;)
Ok. Any idea? I can't catch the article image in twitter cards.
TheLastSuperman
10-31-2016, 07:38 PM
I modified the file related to the Criteria Display and used that variable as the meta, for the image I was actually just about to do that myself for a client when he put all work on hold (so he can budget x-mas etc) so I may have spare time later to whip something up otherwise I'll hide in the dark until the client is ready :p.
Edit: So you know though, probably going to require a query to snag an article image if it exist, use that variable in the template after registering it properly.
PedroMA
11-05-2016, 09:20 PM
I modified the file related to the Criteria Display and used that variable as the meta, for the image I was actually just about to do that myself for a client when he put all work on hold (so he can budget x-mas etc) so I may have spare time later to whip something up otherwise I'll hide in the dark until the client is ready :p.
Edit: So you know though, probably going to require a query to snag an article image if it exist, use that variable in the template after registering it properly.
Yes, my problem is that I can catch the attach info, I can't catch the array information. Can you help me with this problem?
CAG CheechDogg
08-05-2017, 11:10 AM
Was there a way to get an image from a thread for twitter ?
RichieBoy67
04-04-2018, 11:10 AM
Has anyone figured out how to get an image to Twitter?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.