Hi!
I have a slider on my site and it only allows HTML code input.
Is it possible to insert a username into it?
E.g.
Welcome back
$username = getNickName($ID);
?
Any input appreciated! Thanks!
Hi! I have a slider on my site and it only allows HTML code input. Is it possible to insert a username into it? E.g. Welcome back $username = getNickName($ID); ?
Any input appreciated! Thanks! |
Hi! I have a slider on my site and it only allows HTML code input. Is it possible to insert a username into it? E.g. Welcome back $username = getNickName($ID); ?
Any input appreciated! Thanks! Not with HTML. You need to use PHP code. Do some research on the net for how to insert PHP code into HTML code. Heck, here is a link to get you started. http://www.onlamp.com/pub/a/php/2001/05/03/php_foundations.html Then you need to search the forum here for how to get the user name, etc. Geeks, making the world a better place |
Thanks for the tip!
Tried it but didn't work...any clues on what is missing anything here?
<html> <body> <?php require_once( '../../inc/header.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'admin.inc.php' ); require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
$username = getNickName($ID); check_logged(); ?> <h2>$username !</h2> </body> </html> |
I'm not sure where all the code in your last post came from, but from memory, you would access the HTML for the slider and enter this line in the appropriate spot: Html code goes here That should trigger PHP for that line only. You can change "Welcome Back " to whatever you want but the remaining syntax is correct for 7.3.4/5 That's the theory at least. |
Thanks Johnk42!
Tried your code but unfortunately it didn't work. The username does not appear in the slider.
<html> <body> <?php $username = getUsername($id); echo "Welcome Back " . $username; ?> </body> </html> |
Can you post the offending file here please? Otherwise PM me and include the code. |
Hi johnk42,
Thanks again for your help!
There is no file involved. It's just a code snippet , i.e. a text/html box, which is provided as a tool in the slider. I'm using the Revolution slider. Just want to include in the username for logged in users in a slider.
Cheers! |
You have me totally confused, but that's not hard. I just did a search and it seems the Revolution Slider is a Wordpress plugin. If that's the case, I'd be interested to know how you integrated it, or plan to integrate it with Dolphin? Is it a sliding Banner that slots into the home page banner, or do you want it on profile pages? |
You have me totally confused, but that's not hard. I just did a search and it seems the Revolution Slider is a Wordpress plugin. If that's the case, I'd be interested to know how you integrated it, or plan to integrate it with Dolphin? Is it a sliding Banner that slots into the home page banner, or do you want it on profile pages? |
It's actually both a standalone slider and a plugin for wordpress. Have already integrated it into dolphin.
I'm using it as a sliding banner on the home page. So want to welcome members back with their username on one of the slides.
|
It's possible the code contains javascript and you're trying to place the PHP inside a javascript section. Without seeing the code I can't say. I stopped using PHP many years ago and I now use a "hit and miss" method to get things to work. |
sure, thanks anyway! |
Please forgive my rusty responses, but here's something I just recalled from my old PHP days. If a file is an HTML file, the PHP parser probably won't look at it, even though it contains a few lines of PHP. So name the file xxx.php instead of xxx html. That will make the parser realise there's PHP code in the file and force it to read it. If it's called by another file, you will have to change the extension in that file's code. With your new xxx.php file, make the first line <?php then change it back to HTML with ?> Thus the first couple of lines may look like: <?php Run the HTML code until you get to my addition and go back to PHP as shown in my code. I'm so out of touch I'm not sure if you have to close off the php file, but I don't think you do. If it doesn't work, add <?php at the very end, but I really don't think that's necessary. If that sounds messy, here's a schematic: xxx.php <php |
Thanks johnk42 but I only have the option to add the html/text from the slider admin panel. It's a tool which allows you to add in html/text to certain sections of the slides. Hence changing the file name is not possible. Appreciate your time and help. |
<h2>$username !</h2> You can't use variables in HTML like that. You can use PHP code to echo the value to the output. You can grab the user ID from the session cookie and then look up the user name in the database using mysql query. You only need the header.inc.php file in order to get the DB info.
//Get member ID from cookie If you want the full name then grab it instead of the nick. Geeks, making the world a better place |
Also: Further, we also learned how we could quickly output variables from PHP code without all of the hassle of an
Geeks, making the world a better place |
I found this on Stack Overflow. I haven't tried it, but it may just do the job. Once again, use my code because I've tested it and it works. ---------------------------- You can't run PHP in .html files because the server does not recognize that as a valid PHP extension unless you tell it to. To do this you need to create a .htaccess file in your root web directory and add this line to it:
This will tell Apache to process files with a .htm or .html file extension as PHP files. --------------------------------- Try adding the line to your existing .htaccess You can shout me a beer if it works! |
Thanks johnk42 but I don't think that's the solution. Here's a beer anyway. |
For a fee I will do this for you. Geeks, making the world a better place |
thanks but if i wanted to pay someone, i would have already approached anton, modzzz or others. appreciate the offer though. |
thanks but if i wanted to pay someone, i would have already approached anton, modzzz or others. appreciate the offer though. Yeah. Geeks, making the world a better place |
There's nothing like a challenge! The original code I gave you worked perfectly in a PHP block, but not in a Text or HTML block. Hic! |