Professional Web Applications Themes

Adding text to a graphic button - PHP Development

Hello to all, I have to write some scripts for a web side created with Frontpage. My customer used some button generated with FP. He like that I use the same button in my php scripts. I could save a lot of code and time if I could use only one graphic button and then add the text on the fly. My questions, it is possible to do that with PHP. ? I should put about 20 buttons in a table something like that: ¦---------¦ ¦ Button1 ¦ ¦---------¦ ¦ Button2 ¦ ¦---------¦ ¦ Button3 ¦ ¦---------¦ etc. Many thanks ...

  1. #1

    Default Adding text to a graphic button

    Hello to all,

    I have to write some scripts for a web side created with
    Frontpage.
    My customer used some button generated with FP.
    He like that I use the same button in my php scripts. I
    could save a lot of code and time if I could use only one
    graphic button and then add the text on the fly.

    My questions, it is possible to do that with PHP. ?
    I should put about 20 buttons in a table something like
    that:

    ¦---------¦
    ¦ Button1 ¦
    ¦---------¦
    ¦ Button2 ¦
    ¦---------¦
    ¦ Button3 ¦
    ¦---------¦
    etc.

    Many thanks in advance for your help.

    Otto

    l'atelier Ho Guest

  2. #2

    Default Re: Adding text to a graphic button

    See [url]http://www.php.net/manual/en/ref.image.php[/url]

    ---
    Steve

    Steve Guest

  3. #3

    Default Re: Adding text to a graphic button

    *** Steve wrote/escribió (8 Sep 2004 02:02:51 -0700):
    > See [url]http://www.php.net/manual/en/ref.image.php[/url]
    Just a remark: performance increases a great deal if you just generate
    buttons once and store them in a folder, rather than doing it everything
    they're loaded from a page.


    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- Thank you for not e-mailing me your questions
    --
    Alvaro G Vicario Guest

  4. #4

    Default Re: Adding text to a graphic button

    Many thanks four your quick answer.

    I also think it will be faster if I can use a store image. My idee was to
    use a stored image (the button) on only add the text on the fly.
    I will look about the mentionned GD library, if it's possible do do that.

    Regards

    Otto

    > *** Steve wrote/escribió (8 Sep 2004 02:02:51 -0700):
    > > See [url]http://www.php.net/manual/en/ref.image.php[/url]
    >
    > Just a remark: performance increases a great deal if you just generate
    > buttons once and store them in a folder, rather than doing it everything
    > they're loaded from a page.
    >


    l'atelier Ho Guest

  5. #5

    Default Re: Adding text to a graphic button

    l'atelier Ho <atehofreesurf.ch> writes:
    > Hello to all,
    >
    > I have to write some scripts for a web side created with
    > Frontpage.
    > My customer used some button generated with FP.
    > He like that I use the same button in my php scripts. I
    > could save a lot of code and time if I could use only one
    > graphic button and then add the text on the fly.
    >
    > My questions, it is possible to do that with PHP. ?
    > I should put about 20 buttons in a table something like
    > that:
    >
    > ¦---------¦
    > ¦ Button1 ¦
    > ¦---------¦
    > ¦ Button2 ¦
    > ¦---------¦
    > ¦ Button3 ¦
    > ¦---------¦
    > etc.
    >
    > Many thanks in advance for your help.
    >
    > Otto
    >
    If you would like to see a 'working' example of
    some code using True Type fonts, see the stuff at
    [url]http://www.thebook-demo.com/php[/url]

    --
    John
    __________________________________________________ _________________
    John Murtari Software Workshop Inc.
    jmurtarifollowing domain 315.635-1968(x-211) "TheBook.Com" (TM)
    [url]http://thebook.com/[/url]
    John Murtari Guest

  6. #6

    Default Re: Adding text to a graphic button

    I have been experimenting with different ways of doing menus and here is
    one of them that sounds like what you may be trying to do
    [url]http://ncug.net/index2.html[/url]
    It doesn't actually use PHP to do anything ( it is an html ) and it is not
    optimized yet; I need to use loops in the javascript mouse functions.

    I used the same 3 images for all of the buttons (up, down, and clicked) and
    then layered the text over the graphics. The text is 2 layers with the dark
    layer above and to the left of the top layer of text to make it look more
    like it is carved into the button. I need to tweak the fonts a little
    better. I then layered a clear gif over the button and text thet reacts to
    the mouseover and click. I probably could have just used a span there
    instead of the transparent gif.

    The fan at the bottom of the menu is made up of 3 gifs layered over each
    other, the middle one being the animated frame. The fan rotation is kind of
    y because I got tired of playing with it and just wanted to get it put
    in, I'll make a better one when I get to it.

    I have tested this in current versions of Netscape, IE, and Opera. One thing
    I see that I need to get changed is the cursor needs to be "pointer" instead
    of "hand" as hand does not give you a hand in Netscape and pointer does in
    all 3 browsers.

    This uses absolute positions for the components of the menu, but the menu as
    a whole can be wrapped in a span if you need to move it.

    I did a similar menu at [url]http://www.oldenburggroup.com[/url] but there I used an
    external .js file to control the button actions and some loops in php to
    build the menu. The buttons there have the text on them, so there are 42
    images being used.

    "l'atelier Ho" <atehofreesurf.ch> wrote in message
    news:VA.00000268.02f5f7acfreesurf.ch...
    > Hello to all,
    >
    > I have to write some scripts for a web side created with
    > Frontpage.
    > My customer used some button generated with FP.
    > He like that I use the same button in my php scripts. I
    > could save a lot of code and time if I could use only one
    > graphic button and then add the text on the fly.
    >
    > My questions, it is possible to do that with PHP. ?
    > I should put about 20 buttons in a table something like
    > that:
    >
    > ¦---------¦
    > ¦ Button1 ¦
    > ¦---------¦
    > ¦ Button2 ¦
    > ¦---------¦
    > ¦ Button3 ¦
    > ¦---------¦
    > etc.
    >
    > Many thanks in advance for your help.
    >
    > Otto
    >

    Arg Guest

  7. #7

    Default Re: Adding text to a graphic button

    In article <10l0jtipc7lev89corp.supernews.com>, Arg wrote:
    > Newsgroups: alt.comp.lang.php
    > Subject: Re: Adding text to a graphic button
    > Date: Tue, 21 Sep 2004 10:59:42 -0500
    >
    Hello Arg

    I find the following solution:

    I make the button with png8, you can also use GIF. The only
    problem with GIF, some provider do not support it
    (Licence!).

    Write the following PHP script (button.php):


    <?Php
    Header("Content-type: images/png");
    $im = imagecreatefrompng("$img");
    $is = getimagesize("$img");
    if(!isset($fs)) $fs=11;
    $size =
    imagettfbbox($fs,0,"$DOENT_ROOT/fonts/$fn.ttf",$tx);
    $black = ImageColorAllocate ($im, 0, 0, 0);
    $dx = abs($size[2]-$size[0]);
    $dy = abs($size[5]-$size[3]);
    $xpad=$is[0];
    $ypad=$is[1];
    ImageTTFText($im, $fs, 0, ($xpad-$dx)/2, ($ypad+$dy)/2,
    $black, "$DOENT_ROOT/fonts/$fn.ttf", $tx);
    Imagepng($im);
    ImageDestroy($im);
    ?>

    The script calculate the dimension of the picture and the
    dimension of the text do display, then center them in x,y.

    Include next the following link in your another scripts:

    echo("<a href='$ref' target='$targ'>");
    echo("<img border='0'
    src='button.php?fn=arial&fs=$12&tx=Hello&img=butto n.png'>")
    ;

    Place the necessary fonts in /fonts/ you can use windows
    ttf fonts.

    Regards

    Otto



    l'atelier Ho Guest

Similar Threads

  1. Button with graphic skin, transition with states,graphic vanishes???
    By iJames in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: April 30th, 08:19 PM
  2. Dynamically adding Dropdown, Text Box, Add Button and Remove Button
    By Rocky in forum ASP.NET Building Controls
    Replies: 1
    Last Post: November 19th, 07:35 AM
  3. Graphic as form button
    By Ken in forum Dreamweaver AppDev
    Replies: 2
    Last Post: May 3rd, 07:59 PM
  4. Adding a graphic to a PDF file
    By LCrown@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 1
    Last Post: May 13th, 09:34 PM
  5. Using a button graphic to refresh a page
    By spdorsey webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 13th, 04:14 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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139