News:

Join the Facebook Fan Page.

Main Menu

Custom Register Button

Started by gmbhneo, November 06, 2010, 02:01:55 PM

Previous topic - Next topic

gmbhneo

Hey SMF Community :D ...

I got the next question for you ^-^...

How can i create that Register Button on my page? I made that Pic with photoshop and not with php or so ... but it show you the result, i want to get :D

I want that grafic to only be displayed to guests, not to members. BUT i want to show anouther grafic, if your a member.

Hope you got what i mean ^-^

would be awesome if you could tell me how to get there.

For the first, on what php or css i need to do the editing?
Visit my Board at: http://www.neos-shell.de

Mitħrandir

The file that handles the creation of that part of the forum page is index.template.php

You can insert your image just in that place by using CSS rules.

In php you can do different things for logged users and for guests by using this code.

if ($context['user']['is_logged'])
{
          // Do something
}
else
{
         // Echo your image
}


Bye
-- Mithrandir
Proud of using SMF 2.0 on http://polislife.netsons.org/forum

gmbhneo

Quote from: MauroL on November 06, 2010, 02:48:49 PM
The file that handles the creation of that part of the forum page is index.template.php

You can insert your image just in that place by using CSS rules.

In php you can do different things for logged users and for guests by using this code.

if ($context['user']['is_logged'])
{
          // Do something
}
else
{
         // Echo your image
}


Bye

Nice thank you! Thats one thing i dont know before. Now i got a LITTLE bit of my way done ... but what do i need to insert as "Dosomething and Echo your image? Im new to coding ... i just can design ^.^

would be nice if someone could explain me a bit more ^-^...
Visit my Board at: http://www.neos-shell.de

Oya

well, what should happen if the user is logged in?

what should happen if the user is not logged in?

TehCraw

This should work for you. Just place it in index.template.php where you want the image to show. Let us know if you need further assistance.  ;D


global $scripturl;
// Not signed in? :O Display an image then.
if ($context['user']['is_guest'])
	
echo 
'<a href="'$scripturl'?action=register"><img src="put your image URL in here" alt="" /></a>';

// I see you're logged in now. Display the logged in image!
	

elseif ($contex['user']['is_logged'])
	
echo 
'<img src="URL for the logged in image" alt="" />';
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

Mitħrandir

Quote from: ScottyBoy on November 06, 2010, 03:41:57 PM
echo '<a href="', $scripturl, '?action=register"><img src="put your image URL in here" alt="" /></a>';

You must also add a class, or  an id to the <a> tag, in order to customize it via css.
-- Mithrandir
Proud of using SMF 2.0 on http://polislife.netsons.org/forum

gmbhneo

Quote from: ScottyBoy on November 06, 2010, 03:41:57 PM
This should work for you. Just place it in index.template.php where you want the image to show. Let us know if you need further assistance.  ;D


global $scripturl;
// Not signed in? :O Display an image then.
if ($context['user']['is_guest'])
	
echo 
'<a href="'$scripturl'?action=register"><img src="put your image URL in here" alt="" /></a>';

// I see you're logged in now. Display the logged in image!
	

elseif ($contex['user']['is_logged'])
	
echo 
'<img src="URL for the logged in image" alt="" />';


Awesome, that is what i was looking for ... but how do i know, where i have to place it?
Visit my Board at: http://www.neos-shell.de

gmbhneo

Template Parse Error!
There was a problem loading the /Themes/surfandturf/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in .../Themes/surfandturf/index.template.php on line 228

219:                         <div id="toolbar">
220:                            ',template_menu(),'
221:                         </div>
222:                      </div>
223:                   </div>
224:                   <div id="header_left">
225:                      <div id="header_right">
226:                         global $scripturl;
227:                         // Not signed in? :O Display an image then.

228:                         if ($context['user']['is_guest'])

229:                         echo '<a href="', $scripturl, '?action=register"><img src="\Themes\surfandturf\images\Test2.png" alt="Testguest" /></a>';
230:                         // I see you're logged in now. Display the logged in image!
231:                         elseif ($contex['user']['is_logged'])
232:                         echo '<img src="\Themes\surfandturf\images\Test.png" alt="Testmember" />';


This is what i get, after implament your Code ... any ideas?
Visit my Board at: http://www.neos-shell.de

TehCraw

Attach your index.template.php file here, and one of us will fix it for you.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

TehCraw

Also, the URLs of the two images you plan on using would be very helpful.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

gmbhneo

I really want to thank you for all your help!!!

I did the editing for the pictures by myself :) ... i think thats the only thing i understand on that php thing xD
Visit my Board at: http://www.neos-shell.de

TehCraw

Okay, I changed it a little. Can I get the link to your site, so I can give you the appropriate CSS?
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

gmbhneo

Sure its:

hma4ever.de/Forum

I uploaded your file but there is still a problem with it ...
Visit my Board at: http://www.neos-shell.de

TehCraw

Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

gmbhneo

Visit my Board at: http://www.neos-shell.de

TehCraw

Oh my gosh. I can't believe this has taken me so many tries. I'm really sorry about this.

I think I got it this time.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

gmbhneo

awesome, looks like its working now .. but my style is messed up a bit ... any help with it? what do i need to do in my css?
Visit my Board at: http://www.neos-shell.de

TehCraw

Okay, unfortunately I can't help you anymore, because it looks like your site isn't exactly what I would call appropriate. However, I will do the best I can to explain what I've done so far.

Added a new div to your header with the id "custom_icon", so you'll have to edit the CSS for that div to position it where you want. Something like the following...

#custom_icon
{
    position: absolute;
    top: 1px;
    right: 1px;
}

If someone else wants to come in and help, please do.
Good luck.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

gmbhneo

For now, it is working just great :D ... BIG THANKS for all your help !!! :D

the only thing i need to get managed is that you can click through the grafic if your a member, becouse it overlaps the logout button ...
Visit my Board at: http://www.neos-shell.de

TehCraw

I don't think it's possible to click through a graphic (at least not that I know of). Why don't you just move it over a bit?
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

Advertisement: