Creating an HTML or PHP Block

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lynne
    Former vBulletin Support
    • Oct 2004
    • 26255

    Creating an HTML or PHP Block

    The is just a quick article with some examples for creating a Custom HTML/PHP Forum Block

    Creating an HTML Block

    To create the block:
    AdminCP > Forums & Moderators > Forum Blcoks Manager > Add Block
    Select Block Type: Custom HTML/PHP
    CONTINUE
    Title: whatever you want
    Cache Time (in minutes): whatever you want
    Active: Yes
    Content Type: HTML
    Content: examples shown below
    Template to Use: block_html
    SAVE

    Examples for Content for an HTML Block:
    Text:
    HTML Code:
    <p>Hello World</p>
    Click image for larger version

Name:	html1.png
Views:	1
Size:	10.5 KB
ID:	3719829

    An image:
    HTML Code:
    <img src="http://www.vbulletin.com/forum/images/misc/vbulletin4_logo.png" alt="" />
    Click image for larger version

Name:	html2.png
Views:	1
Size:	14.6 KB
ID:	3719827

    Youtube Video[/B]:
    HTML Code:
    <object width="240" height="240"><param name="movie" value="http://www.youtube.com/v/GpcJNEWKzCY&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/GpcJNEWKzCY&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="240" height="240"></embed></object>
    
    <br />
    Click image for larger version

Name:	html3.png
Views:	1
Size:	68.8 KB
ID:	3719828

    Creating a PHP Block

    To create the block:
    AdminCP > Forums & Moderators > Forum Blcoks Manager > Add Block
    Select Block Type: Custom HTML/PHP
    CONTINUE
    Title: whatever you want
    Cache Time (in minutes): whatever you want
    Active: Yes
    Content Type: PHP
    Content: examples shown below
    Template to Use: block_html
    SAVE

    Examples for Content for a PHP Block:
    Text:
    PHP Code:
    $my_output 'Hello, world.';
    return 
    $my_output
    Click image for larger version

Name:	php1.png
Views:	2
Size:	10.3 KB
ID:	3719826

    Using a Variable:
    PHP Code:
    $my_output '<p>Hello 'vB::$vbulletin->userinfo[username].'</p>';
    return 
    $my_output
    Click image for larger version

Name:	php2.png
Views:	1
Size:	10.3 KB
ID:	3719825

    Using a query:
    PHP Code:
    $my_output "Hello "vB::$vbulletin->userinfo['username'];
    $my_output .= "<br />Your last post was in this thread:";
    $myquery =  vB::$db->query_first("
            SELECT
                post.threadid, thread.title 
            FROM " 
    TABLE_PREFIX "post AS post
            INNER JOIN " 
    TABLE_PREFIX "thread AS thread ON (thread.threadid = post.threadid)
            WHERE post.userid = "
    .vB::$vbulletin->userinfo['userid']. "
            ORDER BY post.dateline DESC
        "
    );
    $threadurl '<a href="' fetch_seo_url(thread$myquery) . '" title="'$myquery[title] .'">'$myquery[title] .'</a>';
    $my_output .= "<br />" $threadurl;
    return 
    $my_output
    Click image for larger version

Name:	php3.png
Views:	2
Size:	15.1 KB
ID:	3719830

    If you need help writing the code for one of these widgets, you should request help over on vbulletin.org, the modification site.
    Last edited by Lynne; Fri 21 Jan '11, 11:52am.

    Please don't PM or VM me for support - I only help out in the threads.
    vBulletin Manual & vBulletin 4.0 Code Documentation (API)
    Want help modifying your vbulletin forum? Head on over to vbulletin.org
    If I post CSS and you don't know where it goes, throw it into the additional.css template.

    W3Schools &lt;- awesome site for html/css help

Related Topics

Collapse

Working...