Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: How To Assign a Variable to HREF

  1. #1
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question How To Assign a Variable to HREF

    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

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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.
    Code:
    <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.
    Last edited by Beverleyh; 01-18-2015 at 02:53 PM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    Miker1029 (01-18-2015)

  4. #3
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default LOLSorry

    Quote Originally Posted by Beverleyh View Post
    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.
    Code:
    <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/dynamici...ml5notepad.htm

  5. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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;
    Code:
    <!-- 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;
    Code:
    <a href="javascript:notepad.loadpad('{S_USERNAME}')"
    Last edited by Beverleyh; 01-18-2015 at 04:28 PM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  6. #5
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Ok Thanks

    Quote Originally Posted by Beverleyh View Post
    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;
    Code:
    <!-- 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;
    Code:
    <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
    Last edited by Beverleyh; 01-18-2015 at 04:33 PM.

  7. #6
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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
    Last edited by Miker1029; 01-18-2015 at 05:11 PM.

  8. #7
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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

  9. #8
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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):
    Code:
    <div class="notify">You have mail</div>
    CSS:
    Code:
    .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
    Last edited by Beverleyh; 01-18-2015 at 05:57 PM.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  10. #9
    Join Date
    Jan 2015
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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
    Last edited by Miker1029; 01-18-2015 at 06:36 PM. Reason: Confusion 8-)

  11. #10
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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;
    Code:
    <!-- 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;
    Code:
    .LiveClockIE {
    display: inline-block;
    height:25px;
    }
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Replies: 2
    Last Post: 01-21-2014, 06:56 PM
  2. how to assign variable within query
    By raihan in forum MySQL and other databases
    Replies: 1
    Last Post: 04-26-2013, 01:47 PM
  3. Assign dynamic value to variable
    By Rachele7 in forum JavaScript
    Replies: 1
    Last Post: 07-18-2011, 10:57 AM
  4. Replies: 1
    Last Post: 05-08-2010, 01:46 PM
  5. Replies: 1
    Last Post: 11-14-2008, 06:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •