vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Twitter Card Feature! (https://vborg.vbsupport.ru/showthread.php?t=319694)

ku-med 08-01-2015 01:20 PM

Twitter Card Feature!
 
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! :)

z3r0 08-01-2015 02:47 PM

I added it to the top bit of the headinclude template bellow all the other meta stuff.

Code:

<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> :)
Code:

<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

Code:

<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:

Code:

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

Code:

<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

Code:

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

z3r0 03-15-2016 03:02 PM

According to the twittercard dev page 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

1 Attachment(s)
Quote:

Originally Posted by z3r0 (Post 2567274)
According to the twittercard dev page 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?


All times are GMT. The time now is 06:12 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03115 seconds
  • Memory Usage 1,747KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete