View Full Version : How To Assign a Variable to HREF
Miker1029
01-17-2015, 07:15 PM
Sorry If I'm posting in the Wrong spot, I'm 4 months in on running my forum and am learning....
My question is (And Yes I Googled for this and got a million different ways to do every thing but this..
On my forum the variable user_id is assigned at login...
What I need is:
<a href="javascript:notepad.loadpad('VARIABLE')", I've tried Sticking user_id in there, but it doesn't work, and this script requires a Unique to user ID...
Thanks,
Mike
Beverleyh
01-18-2015, 08:45 AM
Looks like this should be in the JavaScript or PHP forum - we can move it based on further info.
You say that the forum is setting a variable but you do not say what forum software you're using or what coding language. I'm guessing PHP so try echoing the variable.
<a href="javascript:notepad.loadpad('<?php echo $user_id;?>')"
Depending on the forum software, it may use its own PHP? formatting - e.g. phpBB uses PHP open/close tags that look more like HTML comments, plus use of PHP in template files needs to be activated in the ACP - so check the forums/documentation for anything like that. Also check for additional session ids that are sometimes appended to the end of user ids for extra security. Maybe research the code for displaying the username/id as part of a welcome message and take cues from that? That tends to be a common customisation request.
Also, what is the notepad function in the JavaScript? Is that a 3rd party script that you're trying to install? We'll need links to the source site to check that you've installed it correctly. And of course, a link to your site.
If you need more help, please provide more information and a link to your site.
Miker1029
01-18-2015, 03:51 PM
Looks like this should be in the JavaScript or PHP forum - we can move it based on further info.
You say that the forum is setting a variable but you do not say what forum software you're using or what coding language. I'm guessing PHP so try echoing the variable.
<a href="javascript:notepad.loadpad('<?php echo $user_id;?>')"
Depending on the forum software, it may use its own PHP? formatting - e.g. phpBB uses PHP open/close tags that look more like HTML comments, plus use of PHP in template files needs to be activated in the ACP - so check the forums/documentation for anything like that. Also check for additional session ids that are sometimes appended to the end of user ids for extra security. Maybe research the code for displaying the username/id as part of a welcome message and take cues from that? That tends to be a common customisation request.
Also, what is the notepad function in the JavaScript? Is that a 3rd party script that you're trying to install? We'll need links to the source site to check that you've installed it correctly. And of course, a link to your site.
If you need more help, please provide more information and a link to your site.
Sorry About that, And Yes I'm Using PHPBB 3.0.12, And I'm Editing in an HTML Document that controls The Menu Selection System On the Main Index Page, Here's the Code I Stuck together (Don't laugh!):
Sorry, Here's the Original Code: I gave up the other day mid way in editing so I don't have what I tried....
<!-- IF not S_IS_BOT and S_USER_LOGGED_IN --><li><a href="{U_INDEX}">Misc</a><ul><a href="javascript:notepad.loadpad('mynotepad2')">Load NotePad</a></li></ul><!-- ENDIF -->
Where it says "mynotepad2" is where it needs to be a Unique ID to the Notepad Script Load for each user, So I figured, Hey user_id is already assigned at log-in and it's uniqueto each user, So I'm trying to get that to work inside a href="javascript:notepad.loadpad('mynotepad2'), Now this works but it loads the same notepad for all Users, Hence the need for the Unique ID
Thanks for the Help.
Mike
P.S. If It helps here's the link to the Original Code: http://www.dynamicdrive.com/dynamicindex17/html5notepad.htm
Beverleyh
01-18-2015, 04:21 PM
Ok - hopefully this will be reasonably straightforward because I have a phpbb3 forum running too so let's take some code from that.
This will print out a welcome message to each logged in user;
<!-- IF S_USER_LOGGED_IN --><div class="welcome">Hi {S_USERNAME}</div><!-- ENDIF -->
Pop the {S_USERNAME} variable into your javascript function call and hopefully that will be it;
<a href="javascript:notepad.loadpad('{S_USERNAME}')"
Miker1029
01-18-2015, 04:27 PM
Ok - hopefully this will be reasonably straightforward because I have a phpbb3 forum running too so let's take some code from that.
This will print out a welcome message to each logged in user;
<!-- IF S_USER_LOGGED_IN --><div class="welcome">Hi [color="ff0000"{S_USERNAME}[/color]</div><!-- ENDIF -->
Pop the {S_USERNAME} variable into your javascript function call and hopefully that will be it;
<a href="javascript:notepad.loadpad('{S_USERNAME}')"
Appreciate the help, I just got done setting up a test account for you... I'll Give this a shot...
http://android-x86-forums.hostreo.com/
UserName:TestAccount
Password:testing
I've Actually been doing pretty good at Editing, Shoehorning MODS In, Got like 20 Mods Installed, and Only been at it for about 5 Months, When I get to These Format things is when I get stumped and googling an answer is almost impossible...
I'm an OLD School Assembly, CP/M, DOS, BASIC Programmer, So I have some Understanding, Like I said the Formating and Conversion....
Heck in basic, It's simple a$="a":a=asc(a$), print a
And You Get 64, But I Know where and how LOL
Will Get Back To You, Thanks.
Mike
Miker1029
01-18-2015, 04:38 PM
ok that did it, Ummm I have a Question....
I stumbled upon a PHP script that Basically Convert "user_id" to {S_USER_ID} and I plugged that in the same way and it didn't work, And Yes I Know (From What I understand) Mixing PHP and HTML and all that's not good, But it's better then Searching all the files on the forum to find the "RIGHT" place to Put it, LOL...
Thanks for the Help again.
Mike
Miker1029
01-18-2015, 04:47 PM
Also one last Question and I'll stop bothering you (Till the Next Issue 9-) ), (Off-Topic: Would you happen to know where I can find a script that just slides up from the Bottom right for Notifications?? Like PM's Etc?? Been searching for a month a Can't find one....)
Mike
Beverleyh
01-18-2015, 05:48 PM
In light of your phpBB3 forum usage, are you simply asking how to slide up a box from the bottom right corner? (That you will populate yourself with markup and PM-related variables from the phpBB documentation https://wiki.phpbb.com/Global_Template_Variables , to fire on page load or via whatever method you will devise) Or are you asking for a pre-made mod that will do everything all in? If it's the latter, you will probably get a better response from the phpBB forums. If it's the former, you can slide up a div with CSS;
Markup (above the closing </body> tag):
<div class="notify">You have mail</div>CSS:
.notify { display:inline-block; position:fixed; z-index:999; bottom:2em; right:2em; line-height:3em; padding:0 1em; background:yellow; color:black; text-align:center; border:1px solid black;
-webkit-animation:inUp .5s both; animation:inUp .5s both
}
@-webkit-keyframes inUp {
0% { -webkit-transform:translate3d(0,100%,0); transform:translate3d(0,100%,0) }
100% { -webkit-transform:none; transform:none }
}
@keyframes inUp {
0% { -webkit-transform:translate3d(0,100%,0); transform:translate3d(0,100%,0) }
100% { -webkit-transform:none; -ms-transform:none; transform:none }
}
The animation works in IE10+ and modern browser, and the box will just be present on IE7/8/9
Miker1029
01-18-2015, 06:12 PM
No Just pretty much a replacement of the current pop-up systems, The pop-ups that are there now just seem really intrusive, So Just a Simple Small Slide up from the bottom right, after log-in, that in x number of seconds will close (or just a close button), With ability to go to the link of whatever the Notification it may be.....
I'll Insert the code you gave me and see what it's like, Have to try it Local and copy to live when I get it going...
Mike
Ya that CSS Code got me Confused, My Understanding is the CSS code pretty much runs the Enitre Layout Of your Site, So Honestly I've been kind of staying away from it, as not to really mess things up (Although I have Learned to do ALL Updates/Edits Offline), but I went to styles.css (assuming) and didn't see an Appropriate place to insert/replace the code..... I'll look into CSS Via Google, and come back when I know I little More About it, as I don't want to waste your time, when I can read and play and get an Idea of how it works....
But One more Question (LOL), I have a Live JavaScript Time that I Installed a couple days ago, and it does a REALLY Irritating thing, I Load the Page, Go To Click a Link, And The Page Drops done like 2 Pixels when the clock (Finally) Pops-up and I Click the wrong link, Is There any way to like, I guess got the Clock to Pre-Load, So It's ready to Display When The Page is Done Loading?
Mike
Beverleyh
01-19-2015, 10:49 AM
No Just pretty much a replacement of the current pop-up systems, The pop-ups that are there now just seem really intrusive, So Just a Simple Small Slide up from the bottom right, after log-in, that in x number of seconds will close (or just a close button), With ability to go to the link of whatever the Notification it may be.....What I suggest doing is familiarising yourself with the variables from the phpBB3 forum documentation: https://wiki.phpbb.com/Global_Template_Variables and the logic from the template header/footer files, and construct a replacement popup notification yourself.
For example, this IF logic from my previous example would display a div when the user is logged in;
<!-- IF S_USER_LOGGED_IN --><div class="notify">Hi {S_USERNAME}</div><!-- ENDIF --> So explore the template files and linked documentation and do something similar to display a div when a PM is received. S_NEW_PM looks promising.
Ya that CSS Code got me Confused
You can apply the CSS to the page in a number of ways;
1 - Paste it at the bottom of one of your existing stylesheets
2 - Create a new stylesheet and paste it in to that (and link to the stylesheet via the forum's header template file)
3 - Paste it as an internal stylesheet in the <head> section of your forum's header template file
It doesn't replace anything, it is additional.
But One more Question (LOL), I have a Live JavaScript Time that I Installed a couple days ago, and it does a REALLY Irritating thing, I Load the Page, Go To Click a Link, And The Page Drops done like 2 Pixels when the clock (Finally) Pops-up and I Click the wrong link, Is There any way to like, I guess got the Clock to Pre-Load, So It's ready to Display When The Page is Done Loading?
Try making the .LiveClockIE span that the clock is inside into an inline-block with an explicit height;
.LiveClockIE {
display: inline-block;
height:25px;
}
Miker1029
01-19-2015, 10:45 PM
Ahhh i see, Neat, Thanks For that...Will give that and the time thing a try.
Mike
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.