homepage Welcome to WebmasterWorld Guest from 54.197.94.241
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque

Webmaster General Forum

    
What is the Code?
Used on a forum
Lobo




msg:3545524
 2:19 am on Jan 11, 2008 (gmt 0)

I noticed this code used on one of the other forums I frequent and wondered if anyone knew what it was?

basically, whoever is viewing the post their name appears wherever the code is inserted.

eg: " I think <code> username inserted</code> is amasing ... etc..

I've seen it applied to signatures and to post topics,

what is it? where is it? and where can I check it out?

 

jtara




msg:3545542
 3:20 am on Jan 11, 2008 (gmt 0)

<code> is a standard HTML markup element.

It's one of those that denotes specific meaning to the contained text, rather than just visual style. These are referred to as "phrase elements".

<code> is meant to contain examples of computer source code.

Not, mind you - source code that is run in the browser (as with Javascript). But source code that is being presented on the page.

Other phrase elements include <abbr> (abbreviation), <em> (emphasis), <cite> (citation), etc.

If <code> is being used around people's names, then it's being mis-used. That is, unless your name is "Ruby C. 'Python' Javascript".

Lobo




msg:3545610
 5:47 am on Jan 11, 2008 (gmt 0)

nope you completely missed it .. I already know what <code> is!

I was trying to tell you that it is the code inside those elements that I don't know, the code that knows who the member is viewing the page and inserts their username in to the sentence to appear like it is them who is being spoken to or about, if another member views the page then their name is there instead..

Is that clearer?

jtara




msg:3545822
 3:05 pm on Jan 11, 2008 (gmt 0)

the code that knows who the member is viewing the page and inserts their username in to the sentence to appear like it is them who is being spoken to or about, if another member views the page then their name is there instead..

Well, that has nothing to do with the HTML <code> element. If the user's name is surrounded by <code></code> that is a coincidence.

Inserting a user's name would be done by a script or templating system running on the server. There's no way to know the exact code used to implement this, as it could be very different on different sites - different scripting languages on different sites, etc. etc. And since it's on the server side, you can't examine it.

If you were looking for some Javascript to do this - nope.

Why not begin at the beginning and tell us just what you want to do on your site, and what software you have installed on your server?

So, I assume you have some software on your site (message board, commerce system, social networking site, etc. etc.) where you have users that login.
And you want to be able to include the user name on some page.

Let's start with what that software is. (When your users log-in, what are they logging-in to?)

Lobo




msg:3546363
 4:25 am on Jan 12, 2008 (gmt 0)

Perhaps what I am saying is too simple, or is it just me but I can't see where I'm not communicating properly?

ignore <code> nothing to do with it, I was simply indicating that there is some sort of code being used to grab the usersname who is viewing the page and inserting that name in to the sentence or topic of the forum post

I have looked at the source and see no indication of javascript, also looked at the linked JS and saw nothing there, even checked the .css to see if there was an indication of an include there but there wasn't..

I am also assuming that the person has not written any specific php code to use and as this is on a standard forum that it is some sort of nifty add on funny feature, just don't know what it is, where it is or where to find it?

willybfriendly




msg:3546370
 4:51 am on Jan 12, 2008 (gmt 0)

It is some form of server side script. Can be done in any serverside language - PHP, ASP, ColdFusion, etc.

The script is snagging the name, either via cookie or session, pulling the username out of the DB and plugging it into the HTML when it generates the page...

<?php

echo "<b>$usnername</b>";

?>

You will never see the "code" in the HTML. The code is what wrote the HTML.

Clear as mud?

Lobo




msg:3546416
 6:44 am on Jan 12, 2008 (gmt 0)

Clear enough, that's kinda what I thought, just wondered if anyone knew where the snippet for the code may be and what code you would use to generate it when posting..

any ideas?

[edited by: Lobo at 6:45 am (utc) on Jan. 12, 2008]

jtara




msg:3546598
 3:04 pm on Jan 12, 2008 (gmt 0)

I have looked at the source and see no indication of javascript, also looked at the linked JS and saw nothing there, even checked the .css to see if there was an indication of an include there but there wasn't..

You're not going to find it in any of those places. In fact, unless you are the site owner, you're not going to find it at all.

just wondered if anyone knew where the snippet for the code may be and what code you would use to generate it when posting..

Nobody knows. You can't see the source code - it's a server script, and it's not possible for users to view it.

There are hundreds if not thousands of variations on how one might do this.

Depends on where the site stores the user name (A database? Which kind? MySQL? PostgreSQL? Oracle? What database? What table?), what language (PHP, Perl, etc.). Did they write their own software or use a free or commercial software package? Etc. etc. etc.

Again, if you want to implement this on your own site, you'll have to tell us something about your site, and what scripting tools you have available to you.

It's a pretty fundamental things, though, and you'll find out how to do this pretty quickly, reading just about any book on PHP, Perl, Rails, whatever. One of the first examples in any scripting book - "let's greet the user by name..."

There isn't any one way to do this. willybfriendly has shown you *a* way to do it - in PHP. If you want something more specific, you will have to tell us just what tools you are working with. He didn't show how to get a value into $username, but that is site and implementation-specific.

Lobo




msg:3546684
 5:27 pm on Jan 12, 2008 (gmt 0)

I was just interested in looking at the code and playing with it out of interest..

it is a standard phpBB2 forum and assume that the code is added to a php include file and then a certain trigger added to the post that grabs the username and implements the code..

as it is a standard well known forum I am also assuming that this little addon can be found as a download with instructions on how to implement it rather than writing the code in..

I thought maybe if someone here had used it or seen etc they may know where to find the solution

jtara




msg:3546723
 6:48 pm on Jan 12, 2008 (gmt 0)

phpBB uses a templating system for page layouts.

I doubt there is any "plugin" or "extension" needed to do this.

The site owner would modify the template for the page where they want the username to appear. I assume there is a variable name for the username - probably something like $username. So, they would just stick $username (or something similar - I'm not familiar with the templating system that phpBB uses) somewhere in the template.

The templates define how a particular type of page - or section of a page - is layed-out, and what content appears on it. There are probably templates for displaying a post, displaying a list of posts, editing a post, enter a new post, the home page, etc. etc. etc.

Again, this is NOT something that a user can see or alter. It isn't just something that a user can stick in a post.

Why not check on the phpBB support website? If you can't find it in the documentation, then somebody can surely answer your question in the forums there.

Lobo




msg:3546750
 7:28 pm on Jan 12, 2008 (gmt 0)

Thanks mate it's ok I finally found it on phpbb as a Mod ..

once the code is in place you simply type /me in to the post topic of Sig and the username appears there..

for reference it is here.. [phpbb.com...]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved