SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot Netscape's Avatar
    Join Date
    Apr 2000
    Location
    Toronto, ON, Canada
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I've been playing around with open source gallery program that is using PHP as core.

    I've been successful to include the feature "Refer the single picture" but I am unable to include the feature "Print This Photo" from the page where the picture is presented with the whole layout of the page.

    This is a challege for php programmers:
    - how to modify the program to make visitor print only the picture, without the layout of the web site?

    Please see what I mean on this example:

    http://www.fregata.com/gallery/album01/adl

    Best Regards for anyone who can help me,

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I moved this to the PHP forum so you will get some more exposure. What you will need to do is to make the print link open a new window passing the id of the photo to it, then in that new window you need to use javascript to print the window on load so your popup.php would look something like

    popup.php
    Code:
    <?
    mysql_connect();
    $result = mysql_query("SELECT picturename from tablename WHERE idfield = $id");
    $row = mysql_fetch_array($result);
    ?>
    <html>
    <head>
    	<title>Untitled</title>
    </head>
    
    <body onLoad="self.print(); " marginwidth="0" marginheight="0" border="0" leftmargin="0" topmargin="0">
    <img src="<?=$row["picturefieldname"]?>">
    </body>
    </html>

    Then you would need your link to use javascript to open the window, I am not sure how your script works, but if you show some code we can help more.


    <a href="javascript:window.open('popup.php?id=<?=$id?>', 'popup', 'width=300,height=300'); ">print this picture</a>
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think I can help you with the code, but those girls are HOT (with a capital H-O-T)
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  4. #4
    SitePoint Zealot Netscape's Avatar
    Join Date
    Apr 2000
    Location
    Toronto, ON, Canada
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I would like to thank freddydoesphp for ideas that you gave me.
    Actually, the program does not use Mysql...
    But your idea kicked in, so I came up with solution, getting advantage of variables already present in the code:

    Code:
    <?
    
    // on the page where you want it to be refered
    
    $full_URL = $album->getPhotoTag($index, $full);
    $full_URL = urlencode($full_URL);
    echo "<a href=http://www.fregata.com/printphoto/print.php?url=$full_URL onClick=\"NewWindow(this.href,'name','660','500', '0', '250', 'yes','no', 'no', 'no', 'no', 'no');return false;\"><img src=http://www.fregata.com/images/print.gif width=15 height=11 border=0 alt=Print>&nbsp;Print 
          This Photo</a></font>&nbsp;";
    ?>
    and print.php was easy:

    Code:
    <?
    echo "$url";
    
    ?>
    PHP is definitelly fun :-)

    Thanks for help again - I approtiate it!

    Best Regards,

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So then you can take it a step further by using PHP to get the height and width of an image by using GetImageSize(). This returns an array you can use to add 20 pixels to both the height and widt hof the image then echo those vars in your javascript so you can open a window which seems to be custom sized for the image.

    Code:
    $dimen = GetImageSize($full_URL);
    $width = $dimen[0] + 20;
    $height = $dimen[1] + 20;
    echo "<a href=http://www.fregata.com/printphoto/print.php?url=$full_URL onClick=\"NewWindow(this.href,'name','$width','$height', '0', '250', 'yes','no', 'no', 'no', 'no', 'no');return false;\"><img src=http://www.fregata.com/images/print.gif width=15 height=11 border=0 alt=Print> Print 
          This Photo</a></font> ";
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •