Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-02-2014, 01:18 AM
SoHelpMe SoHelpMe is offline
 
Join Date: Apr 2014
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Posting Variable Data On Form? Display/Run .html

Hello,
I have a forum that I am putting together and it would really be an awesome feature if on the page header I could display some variable data from another source that changes daily. I have some html written and attached below that I can execute in a browser to go to another page and parse out the data I would want to display. I just have very little vbulletin experience and I was wondering what options you guys might come up with to allow me to pull this off. I have even considered looking into the source code for a calendar plug in to see if I might be able to leverage it's approach to doing this. Just to be clear basically I want to display some custom variable txt in the header on all my pages, just think it as a custom quote for the day or a number of stock quotes that change daily. Here is the code that I can run to pull my data note the page reference within the htm is just for an example.

example.html
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$.support.cors = true;
$( document ).ready(function() {
$.ajax(
{
url: 'http://www.forwebexample.com/downone/rrm.php',
type: 'GET',
success: function (result) {
var localContent = $(result).find('#localcontent');
var table = $(localContent).find('table:nth-child(2)');

$(table).find('tr').each(function(){
var row = $(this);
if(row.find('td:eq(0)').html() === 'LOOKUP KEY')
{
var itema = row.find('td:eq(1)').html();
var itemb = row.find('td:eq(2)').html();
var itemc = row.find('td:eq(3)').html();
var itemd = row.find('td:eq(4)').html();
var iteme = row.find('td:eq(5)').html();
var itemf = row.find('td:eq(6)').html();
/*display only*/
var data = 'itema: ' + itema + '<br/> itemb: ' + itemb + '<br/> itemc:' + itemc +
'<br/>itemd: ' + itemd + '<br/>iteme: ' + iteme + '<br/>itemf: ' + itemf;
$('#content').html(data);
/*end display*/
}
});
},
error: function(xhr, status, errorThrown) {
alert(errorThrown);
}
})
});
</script>
</head>
<body>
<!--html element for display-->
<div id='content'></div>
</body>
</html>
Reply With Quote
  #2  
Old 05-02-2014, 02:17 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You enter html changes into templates. So, what templates are you wanting to enter that html into? You could probably put it into the header template (minus the <html>, <body>, and <head> tags).
Reply With Quote
  #3  
Old 05-02-2014, 01:11 PM
SoHelpMe SoHelpMe is offline
 
Join Date: Apr 2014
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Base on the recomendation from Lynne I would like to explore the idea of adding the code I have (minus the tags that were suggested I remove) into the header template file. I am a complete newbie to vB and have very little html or xml experience however so I am hopeful to get a little more help on this. After the suggestion I looked around for something that was obvious to me as being the header template but no luck. FYI, I am using a style called color theory if that is even in play for discussion purposes. In any case can someone help me locate my header template. In addition can someone take the code example I have below and past it into a typical header template file so that I can mimic precisely what was suggested. I know this is some serious hand holding on this topic but rest assured your assistance is really appreciated.

Thanks,
Joe

--------------- Added [DATE]1399118629[/DATE] at [TIME]1399118629[/TIME] ---------------

I am trying to explore the idea supplied by Lynne for adding my code to the header template. I have been doing some reading and have found that the header template can be edditted through AdminCP style manager and I found my header section and below if the code from my site. Am I on the correct track? If so can someone repost me with an example of how my code in this post would be copied and pasted into the header section below. If I should be looking in another Admin CP section or editing a file directly and not through AdminCP please let me know. Thanks.............


<div id="headerMain">
<div id="topBar">
<div class="loginBox">
<vb:if condition="$show['member']">
<div id="toplinks" class="toplinks">
<ul class="isuser">
<li><a href="login.php?{vb:raw session.sessionurl}do=logout&amp;logouthash={vb:ra w bbuserinfo.logouthash}" onclick="return log_out('{vb:rawphrase sure_you_want_to_log_out}')">{vb:rawphrase log_out}</a></li>
<vb:if condition="$show['registerbutton']">
<li><a href="register.php{vb:raw session.sessionurl_q}" rel="nofollow">{vb:rawphrase register}</a></li>
</vb:if>
<li><a href="usercp.php{vb:raw session.sessionurl_q}">{vb:rawphrase control_panel}</a></li>
<li><a href="{vb:link member, {vb:raw bbuserinfo}}">{vb:rawphrase your_profile}</a></li>
<vb:if condition="$notifications_total">
<li class="popupmenu notifications" id="notifications">
<a class="popupctrl" href="usercp.php{vb:raw session.sessionurl_q}">{vb:rawphrase your_notifications}: <span class="notifications-number"><strong>{vb:raw notifications_total}</strong></span></a>
<ul class="popupbody popuphover">
{vb:raw notifications_menubits}
</ul>
</li>
<vb:else />
<li class="popupmenu nonotifications" id="nonotifications">
<a class="popupctrl" href="usercp.php{vb:raw session.sessionurl_q}">{vb:rawphrase your_notifications}</a>
<ul class="popupbody popuphover">
<li>{vb:rawphrase no_new_messages}</li>
<li><a href="private.php{vb:raw session.sessionurl_q}">{vb:rawphrase inbox}</a></li>
</ul>
</li>
</vb:if>
<li class="welcomelink">{vb:rawphrase welcome_x_link_y, {vb:raw bbuserinfo.username}, {vb:link member, {vb:raw bbuserinfo}}}</li>
</ul>
{vb:raw template_hook.header_userinfo}
<vb:comment><p>{vb:rawphrase last_visited_x_at_y, {vb:raw pmbox.lastvisitdate}, {vb:raw pmbox.lastvisittime}}</p></vb:comment>
</div>
<vb:else />
<script type="text/javascript" src="clientscript/vbulletin_md5.js?v={vb:raw vboptions.simpleversion}"></script>
<form action="login.php?{vb:raw session.sessionurl}do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, {vb:raw show.nopasswordempty})">
<ul>
<li>{vb:rawphrase log_in}:</li>
<li><div class="inputBox"><input type="text" class="loginInput" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="<vb:if condition="$username">{vb:raw username}<vb:else />{vb:rawphrase username}</vb:if>" onfocus="if (this.value == '<vb:if condition="$username">{vb:raw username}<vb:else />{vb:rawphrase username}</vb:if>'){this.value='';}" onblur="if (this.value == '') {this.value='<vb:if condition="$username">{vb:raw username}<vb:else />{vb:rawphrase username}</vb:if>';}"/></div></li>
<li><div class="inputBox"><input type="password" class="loginInput" tabindex="102" name="vb_login_password" id="navbar_password" size="10" /></div></li>
<li class="rememberMe"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" id="cb_cookieuser_navbar" class="cb_cookieuser_navbar" accesskey="c" tabindex="103" /> Save?</label></li>

<li class="loginButton"><input type="image" src="images/styles/ColorTheory/style/loginButton.gif" value="{vb:rawphrase log_in}" alt="Submit" tabindex="104" accesskey="s" /></li>
</ul>
<input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="vb_login_md5password" />
<input type="hidden" name="vb_login_md5password_utf" />
</form>
</vb:if>
</div>
<div class="searchBox">
<div class="searchBoxBody">
<div class="searchBoxLeft"><div class="searchBoxRight">
<form action="search.php?do=process" method="post" id="navbar_search">
<input type="hidden" name="s" value="{vb:raw session.sessionurl}" />
<input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
<input type="hidden" name="do" value="process" />
<ul>
<li>Search our forums:</li>
<li><div class="searchInputBox"><input class="searchInput" type="text" name="query" tabindex="1004" value="" /></div></li>
<li><input type="image" src="images/styles/ColorTheory/style/searchButton.gif" value="{vb:rawphrase search}" alt="{vb:rawphrase search}" /></li>
</ul>
</form>
</div></div>
</div>
</div>
</div>
<div id="headerBox">
<div class="headerWrap">
<a name="top" href="{vb:raw vboptions.forumhome}.php{vb:raw session.sessionurl_q}" id="logo"><img src="{vb:stylevar titleimage}" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" /></a>
<div class="bannerBox">
<script type="text/javascript"><!--
google_ad_client = "pub-9263831296728856";
/* 468x60, created 8/20/09 */
google_ad_slot = "0441202397";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>
</div>
</div>

My header currently looks like this:

Ideally I would like to have the variable info show between the fish and web error. Ideally I would move the fish location a little to the left and the web error moved a little to the right (the web error I am asking about fixing in a seperate thread https://vborg.vbsupport.ru/showthread.php?t=311010).
Reply With Quote
  #4  
Old 05-04-2014, 03:23 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Seeing all that template code doesn't help. What did you change? That is really all that is important.
Reply With Quote
  #5  
Old 05-04-2014, 05:02 AM
SoHelpMe SoHelpMe is offline
 
Join Date: Apr 2014
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

At this point I haven't changed anything in the header template file except for commenting out one line that was related to google adsense and giving me a web page error as can be seen by the screen capture. I am unsure how/where precisely I would add my code to the template and if I added it how do I specify/instruct where the txt will be displayed on the header. Suggestions on how to move forward or what documents/web pages I should study over would be appreciated. Thanks
Reply With Quote
  #6  
Old 05-04-2014, 04:33 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You would want to add the script code to the headinclude template and then add the stuff inside the body tags to your header template wherever you want the stuff to display.
Reply With Quote
  #7  
Old 05-04-2014, 06:46 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

And please, for gods sake and readability, use code tags when pasting lots of code. This is hardly readable.
Reply With Quote
  #8  
Old 05-04-2014, 08:57 PM
Seven Skins's Avatar
Seven Skins Seven Skins is offline
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

As lynne said do this...

Add the code below in the headinclude template:

HTML Code:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
    $.support.cors = true;
    $(document).ready(function() {
        $.ajax({
            url: 'http://www.srh.noaa.gov/ffc/html/rrm.php',
            type: 'GET',
            success: function(result) {
                var localContent = $(result).find('#localcontent');
                var table = $(localContent).find('table:nth-child(2)');
 
                $(table).find('tr').each(function() {
                    var row = $(this);
                    if (row.find('td:eq(0)').html() === 'LAKE HARTWELL') {
                        var stationId = row.find('td:eq(1)').html();
                        var floodLevel = row.find('td:eq(2)').html();
                        var summerLevel = row.find('td:eq(3)').html();
                        var poolLevel = row.find('td:eq(4)').html();
                        var change = row.find('td:eq(5)').html();
                        var precipitation = row.find('td:eq(6)').html(); /*display only*/
                        var data = 'StationId: ' + stationId + '<br/> Flood Level: ' + floodLevel + '<br/> Summber Level:' + summerLevel + '<br/>Pool Level: ' + poolLevel + '<br/>Change: ' + change + '<br/>Precipitation: ' + precipitation;
                        $('#contentHartwell').html(data); /*end display*/
                    }
                });
            }, error: function(xhr, status, errorThrown) {
                alert(errorThrown);
            }
        })
    });
</script>

And add this to the header where you need the text to display:


HTML Code:
<div id='contentHartwell'></div>
Reply With Quote
Благодарность от:
Lynne
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:05 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.04427 seconds
  • Memory Usage 2,260KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete