View Full Version : Posting Variable Data On Form? Display/Run .html
SoHelpMe
05-02-2014, 01:18 AM
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>
Lynne
05-02-2014, 02:17 AM
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).
SoHelpMe
05-02-2014, 01:11 PM
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 1399118629 at 1399118629 ---------------
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&logouthash={vb:raw 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:
https://vborg.vbsupport.ru/external/2014/05/36.jpg
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).
Lynne
05-04-2014, 03:23 AM
Seeing all that template code doesn't help. What did you change? That is really all that is important.
SoHelpMe
05-04-2014, 05:02 AM
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
Lynne
05-04-2014, 04:33 PM
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.
cellarius
05-04-2014, 06:46 PM
And please, for gods sake and readability, use code tags when pasting lots of code. This is hardly readable.
Seven Skins
05-04-2014, 08:57 PM
As lynne said do this...
Add the code below in the headinclude template:
<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:
<div id='contentHartwell'></div>
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.