SitePoint Sponsor

User Tag List

Page 2 of 3 FirstFirst 123 LastLast
Results 26 to 50 of 62
  1. #26
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On your upload form, you have not changed this line:

    PHP Code:
    $entry $_POST['entry']; 
    Becuase we renamed the textarea this now should read:

    PHP Code:
    $entry $_POST['message']; 
    Also I noticed that the <textarea> form field I did a typo, so replace it with this:
    PHP Code:
    <p><textarea name="message" cols="80" rows="20" id="message"
    Change that code and re-do a test and it should all work.
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #27
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok but without making these changes for some reason it now works lol

    I noticed the last one with the textarea name there was an extra id..

    I changed the path to the smiley face image for some reason the display page wasnt finding ../images/smiling.gif this path is used on the blog form. I changed the path too '../jecgardner/images/smiling.gif' and it works!!

    Thanks for your help webnoob! Hopefuly I can add my own images now

    Any advice on how to add a second and third image (im sure I can figure this one out)?

    Just wondering a few more things tho if its ok to ask :-p
    Is it possible to make a word have a dotted unline like making the word bold and italic? How would I add these options + adding the
    Code:

    code

    option?? This would be amazing! Im still amazed the smiley face works!!!

    Thanks again!
    Last edited by shtoom; Feb 5, 2007 at 11:27.

  3. #28
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im glad it works, please still make the changes I mentioned as they really need to be done (good programming ethics). To add more smileys, just add to the script you have, leave the javascript as it is. Here we go again

    Lets say you want a wink smiley, just add it like this:

    PHP FUNCTION:

    PHP Code:
    <?php 

    function smiley($content) {

        
    $find[] = ":smile:";
        
    $replace[] = "<img src='../images/smiling.gif' alt='smile'>";
        
    $find[] = ":wink:"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../images/wink.gif' alt='wink'>";//NEW WINKING SMILEY REPLACE


        
    echo str_replace($find$replace$content);

    }  

    ?>
    Then on your upload page, just add the image tag again for the winking smiley instead, so:

    HTML Code:
    <img src="../images/icons/emoticons/wink.gif" onClick="addsmiley(':wink:')">
    Notice the change? I changed the :smiley: to :wink: (in the onClick="addsmiley()"), the rest is already set up for you.

    Thats all you need to do to add smiley's, you can have as many as you want, just keep adding.

    Now I'll prepare Lesson 2 on making text bold and colored, and also underlined. Ill do it later on this evening as I am still working at the moment

    Let me know if you have any problems
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  4. #29
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright excellent I cant wait to learn more!!!!! Thanks!!!!!!

    BTW I changed message to entry now everywhere (including in the JS). Everything works great! Thanks!

    I know im going too fast asking how to add the dotted underline and code highlighting when I cant even do lesson 2 yet

    Basically below is a screen shot from a site where some words have a dotted unerline and I thought it would be cool if this could be used on my blog..
    If you have any idea how to do this that would be cool!!!! I realize it isnt done in a blog form so I have no idea if it can be done.. Saying this can the bullet points be done lol..


    (http://codegrrl.com/!/tutorials/cate...0A%20Blog/P10/)

    Do you think its possible to add a [code] tag like here where the background changes colour highlighting code??
    Code:
    wooow

  5. #30
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey webnoob -

    in your function you have...

    PHP Code:
    $find[] = ":smile:";
        
    $replace[] = "<img src='../images/smiling.gif' alt='smile'>";
        
    $find[] = ":wink:"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../images/wink.gif' alt='wink'>";//NEW WINKING SMILEY REPLACE 
    I'm just reading through and trying to learn stuff as well...what is the [] doing at the end of each variable?
    No, I REALLY dislike having to use Joomla.

  6. #31
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is adding the bits between the "" to the array of $find and $replace.

    So when we use this:

    PHP Code:
    echo str_replace($find$replace$content); 
    It will basically look for everything in the $fiind array and replace it with the corresponding number in the $replace array.

    While we are talking about it, make sure that you match the numbers up properly in each array, as an example:

    find1 = smileyfind
    replace1 = smileyreplace
    find2 = winkind
    replace2 = winkreplace

    That is correct, but this is not:

    find1 = smileyfind
    replace1 = winkreplace
    find2 = winkind
    replace2 = smileyreplace

    As you can see you will find "smiley1" and replace it with "winkreplace" instead of smileyreplace.
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  7. #32
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so you don't need to declare those as arrays first?

    PHP Code:
    $find = array(); 
    interesting...
    No, I REALLY dislike having to use Joomla.

  8. #33
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  9. #34
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok check out the faces I made a few hehe
    http://www.newmedia.lincoln.ac.uk/jecgardner/

    A question about your array example
    find1 = smileyfind
    replace1 = smileyreplace
    find2 = winkind
    replace2 = winkreplace
    why isnt it this? I didnt add numbers to add the other faces..
    find = smileyfind
    replace = smileyreplace
    find = winkind
    replace = winkreplace

  10. #35
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by shtoom View Post
    Ok check out the faces I made a few hehe
    http://www.newmedia.lincoln.ac.uk/jecgardner/

    A question about your array example


    why isnt it this? I didnt add numbers to add the other faces..
    find = smileyfind
    replace = smileyreplace
    find = winkind
    replace = winkreplace
    I used it as an example, basically im saying that you need to make sure that the find and replace are in the same order, so find 1 matches replace 1.
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  11. #36
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    o ok cool!!

    Hows lesson 2 coming along

  12. #37
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ill have to get that done tomorrow, I was shipped off to an SEO conference today so I didn't get chance to write it up
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  13. #38
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet! I cant wait! Thanks for everything!

  14. #39
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok here we go, making text bold, underlined, and putting a code block around it is pretty much the same principle as adding smiley's in but with a little addition. We need to create our tags to make text bold, so we need a start tag to represent the start of the bold text and also an ending tag which shows us when we stop the bold text. I use these [ b ] [ / b ] (you may note that I have put a space in between each character, this is only so they show here and shouldnt be there

    So by using the code we created for the smiley's we can build this in using span tags:

    Smiley PHP Function

    PHP Code:
    <?php

    function smiley($content) {

        
    $find[] = ":smile:";
        
    $replace[] = "<img src='../images/smiling.gif' alt='smile'>";
        
    $find[] = ":wink:"
        
    $replace[] = "<img src='../images/wink.gif' alt='wink'>";
        echo 
    str_replace($find$replace$content);
        
    $find[] = "[b]"//Look for bold tag
        
    $replace "<span style='font-weight: bold'>"//Replace with span tag
        
    $find "[/b]"//Look for bold end tag
        
    $replace "</span>"//replace with end span

    }  

    ?>
    The javascript can stay the same on the upload page and all you need to add is this (put it with the other smiley click buttons you have)

    HTML Code:
    <img src="../images/icons/emoticons/bold.gif" onClick="addsmiley('[b][/b]')">
    That will put the tags on the page and you just puy your content between them, i.e "This content will go bold"

    The principle is the same for the underline and italics, you can also do this for a code box, create the div in your stylesheet and use the find, replace to start and finish the div.

    Ill let you try and figure those ones out

    Let me know if you have any problems
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  15. #40
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi I added exactly what you've done but it doesnt work.. check my site it displays the entry like this:
    [ b ]nice[ / b ] [ i ]nice[ / i ][ u ]nice[ / u ]

    should I change onClick="addsmiley" ?

    also if you highlight the text you want and then click the bold button can the text wrap inside the tags?

    You've got my thinking about how to do the css code tag.. If I can figure that out then I recon I figure out how to change the face vertical alignment. Nothing too important but when I look at the faces posted in these forums they are aligned better with the text .. more balanced

  16. #41
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can u post the php code you have used please

    EDIT: just look at my example code and I forgot a semicolon at the end of the style attribute, change it to this:

    PHP Code:
    $replace "<span style='font-weight: bold;'>"
    Hopefully that will fix it for you.
    Last edited by webnoob; Feb 7, 2007 at 08:37.
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  17. #42
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Display page:
    PHP Code:
    <?php

    function smiley($content) {
        
    $find[] = ":)";
        
    $replace[] = "<img src='../jecgardner/images/smileg.gif' alt='smile'>";
        
    $find[] = ";)"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/wink.gif' alt='wink'>";//NEW WINKING SMILEY REPLACE
        
    $find[] = ":/"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facehm.gif' alt='hmm'>";//NEW WINKING SMILEY REPLACE
        
    $find[] = ":|"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facethink.gif' alt='think'>";//NEW WINKING SMILEY REPLACE
        
    $find[] = ":c"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/faceconfused.gif' alt='confused'>";//NEW WINKING SMILEY REPLACE
        
    echo str_replace($find$replace$content);
     
        
    $find[] = "[b]"//Look for bold tag
        
    $replace "<span style='font-weight: bold;'>";  //Replace with span tag
        
    $find "[/b]"//Look for bold end tag
        
    $replace "</span>"//replace with end span

    }  

    ?>
    Form page:
    HTML Code:
    <img src="../images/bold.gif" onClick="addsmiley('[b][/b]')">

  18. #43
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have added the find, replace at the end of the function, after the str_replace function.

    Change it to this:

    PHP Code:
    <?php

    function smiley($content) {
        
    $find[] = ":)";
        
    $replace[] = "<img src='../jecgardner/images/smileg.gif' alt='smile'>";
        
    $find[] = ";)"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/wink.gif' alt='wink'>";//NEW WINKING SMILEY REPLACE
        
    $find[] = ":/"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facehm.gif' alt='hmm'>";//NEW WINKING SMILEY REPLACE
        
    $find[] = ":|"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facethink.gif' alt='think'>";//NEW WINKING SMILEY REPLACE
        
    $find[] = ":c"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/faceconfused.gif' alt='confused'>";//NEW WINKING SMILEY REPLACE
        
        
    $find[] = "[b]"//Look for bold tag
        
    $replace "<span style='font-weight: bold;'>";  //Replace with span tag
        
    $find "[/b]"//Look for bold end tag
        
    $replace "</span>"//replace with end span

        
    echo str_replace($find$replace$content);//This always needs to be at the end of the function
    }  

    ?>
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  19. #44
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ah hehe

  20. #45
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On display page I added a new fuction effex and changed the code on the form aswel.
    This is what the display page looked like.. ive gone back to the old code becuase this one is wild
    PHP Code:
    <?php

    function smiley($content) {
        
    $find[] = ":)";
        
    $replace[] = "<img src='../jecgardner/images/smileg.gif' alt='smile'>";
        
    $find[] = ";)"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/wink.gif' alt='wink'>";//NEW SMILEY REPLACE
        
    $find[] = ":/"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facehm.gif' alt='hmm'>";//NEW SMILEY REPLACE
        
    $find[] = ":|"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facethink.gif' alt='think'>";//NEW SMILEY REPLACE
        
    $find[] = ":c"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/faceconfused.gif' alt='confused'>";//NEW SMILEY REPLACE
        
    echo str_replace($find$replace$content);//This always needs to be at the end of the function

        
    function 
    effex($content) {    
        
    $find[] = "[b]"//Look for bold tag
        
    $replace "<span style='font-weight: bold;'>";  //Replace with span tag
        
    $find "[/b]"//Look for bold end tag
        
    $replace "</span>"//replace with end span
        
    echo str_replace($find$replace$content);//This always needs to be at the end of the function
    }  

    ?>
    Last edited by shtoom; Feb 7, 2007 at 10:17.

  21. #46
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    o its prolly coz I have something in the css using span already

    I just added this in the css
    Code:
     span.blogbold{
      font-weight: bold;
    	}
    I changed this line on the php display page:
    PHP Code:
     $replace "<span style='font-weight: bold;'>"
    to
    PHP Code:
    $replace "<span class='blogbold;'>";  //Replace with span tag 
    I also tried variations like <span class=blogbold>"; .. but no luck

    This is what the code looks like now:
    PHP Code:
    <?php

    function smiley($content) {
        
    $find[] = ":)";
        
    $replace[] = "<img src='../jecgardner/images/smileg.gif' alt='smile'>";
        
    $find[] = ";)"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/wink.gif' alt='wink'>";//NEW SMILEY REPLACE
        
    $find[] = ":/"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facehm.gif' alt='hmm'>";//NEW SMILEY REPLACE
        
    $find[] = ":|"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facethink.gif' alt='think'>";//NEW SMILEY REPLACE
        
    $find[] = ":c"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/faceconfused.gif' alt='confused'>";//NEW SMILEY REPLACE
        
        
    $find[] = "[b]"//Look for bold tag
        
    $replace "<span class='blogbold;'>";  //Replace with span tag
        
    $find "[/b]"//Look for bold end tag
        
    $replace "</span>"//replace with end span

        
    echo str_replace($find$replace$content);//This always needs to be at the end of the function
    }  

    ?>

  22. #47
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to keep it all in one function or you wont be able to have smileys and font changes. your style sheet wont matter, you can have as many spans as you like. show me the code you are echo ing out the content with

    EDIT: Just noticed something that will fix it, use this function and replace the 2 you have:

    PHP Code:
    <?php

    function smiley($content) {
        
    $find[] = ":)";
        
    $replace[] = "<img src='../jecgardner/images/smileg.gif' alt='smile'>";
        
    $find[] = ";)"//NEW WINKING SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/wink.gif' alt='wink'>";//NEW SMILEY REPLACE
        
    $find[] = ":/"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facehm.gif' alt='hmm'>";//NEW SMILEY REPLACE
        
    $find[] = ":|"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/facethink.gif' alt='think'>";//NEW SMILEY REPLACE
        
    $find[] = ":c"//NEW SMILEY SEARCH
        
    $replace[] = "<img src='../jecgardner/images/faceconfused.gif' alt='confused'>";//NEW SMILEY REPLACE

        
    $find[] = "[b]"//Look for bold tag
        
    $replace[] = "<span style='font-weight: bold;'>";  //Replace with span tag
        
    $find[] = "[/b]"//Look for bold end tag
        
    $replace[] = "</span>"//replace with end span

        
    echo str_replace($find$replace$content);//This always needs to be at the end of the function
    }  

    ?>
    I forgot to add some [] in
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  23. #48
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works! I added italic and underline

    lol should of noticed [] was missing specially after crowden asked what its purpose was

    any ideas how to do a dotted underline??

    If I want to call div.codebox from the css would this be the right code?
    $replace = "<div id=codebox>";

  24. #49
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes calling that div will work, just remember to end it as well </div>.

    As far as a dotted underline, im pretty sure you can do it in CSS, but im not sure how. I'll get back to you on it. Try and find out and let me know if you dont come up with anything.

    Glad it works for you
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  25. #50
    SitePoint Addict
    Join Date
    Dec 2006
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cool thnx

    Ill keep you posted on my progress.

    All the best!


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
  •