Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #31  
Old 04-05-2007, 03:46 AM
RAitch Offline
pixelpost guru
 
Join Date: Aug 2006
Location: Ontario
Posts: 115
Quote:
Originally Posted by dakwegmo View Post
It will work if you're executing the PHP code in the same page page as the JavaScript. It's a simpler solution than the HTTP request, and unless you're adding several photos a day, the number of images isn't going to change enough to really warrant using AJAX. It would make sense to do this if you were trying to avoid using PHP, but eventually everything will need to be embedded in an addon anyway, so putting everything in one file would be more advantageous in the long run.
If what you're saying is true, shouldn't I be able to do something like this:
Code:
<script type="text/javascript">
var imagecount;
var pageLoad = function() {
	imagecount = <?php include("templates/mytemplate/carousel.php"); ?>;

    var carousel = new YAHOO.extension.Carousel("mycarousel", 
        {
            numVisible:        7,
            animationSpeed:   .5,
            scrollInc:         7,
            navMargin:         40,
            autoplay:		10000,
            size:			imagecount,
            prevElement:     "prev-arrow",
            nextElement:     "next-arrow",
            prevButtonStateHandler:   handlePrevButtonState,
            nextButtonStateHandler:   handleNextButtonState
        }
    );
};

YAHOO.util.Event.addListener(window, 'load', pageLoad);

</script>
As far as the addon goes... if I can get it to work correctly as a hack, I'm fine with that. I might take it as far as an addon, but that's not the initial plan.
__________________
My Gallery
Reply With Quote
  #32  
Old 04-05-2007, 08:04 AM
blinking8s's Avatar
blinking8s+ Offline
über loafer
 
Join Date: Oct 2004
Location: Bowling Green, Ky
Posts: 3,428
Send a message via ICQ to blinking8s Send a message via AIM to blinking8s Send a message via MSN to blinking8s Send a message via Skype™ to blinking8s
hacks are cool too! the system has to have something fun for the geeks...but addons let everyone use them, so they are normally better
__________________
i should say more clever stuff
Reply With Quote
  #33  
Old 04-05-2007, 12:48 PM
dakwegmo's Avatar
dakwegmo+ Offline
Team Pixelpost
 
Join Date: Jul 2005
Location: West of Between
Posts: 689
RAitch, I don't think using an include there will do what you want it to. It might work if the only output from carousel.php was the number of images. If the file your including is the PHP code you posted earlier, it won't work because it's going to assign all of the HTML output by PHP not just the number.

Essentially what that translates to is:
Code:
imagecount = <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title>Get Image Count</title>     
</head>
<body>
    <div id="divInfoToReturn"> 123 </div>
</body>
</html>;
Obviously, this would cause all kinds of problems with JavaScript.

Using an include might work if the carousel.php looked like this:
PHP Code:
<?php
   
    
//variable to hold count
    
$sInfo "";
   
    
//database information
    
$sDBServer "server";
    
$sDBName "pixelpost";
    
$sDBUsername "user";
    
$sDBPassword "password";

    
//create the SQL query string
    
$sQuery "Select count(*) as imagecount from pixelpost_pixelpost";
             
    
//make the database connection
    
$oLink mysql_connect($sDBServer,$sDBUsername,$sDBPassword);
    @
mysql_select_db($sDBName) or $sInfo "Unable to open database";
       
    if(
$sInfo == '') {
        if(
$oResult mysql_query($sQuery) and mysql_num_rows($oResult) > 0) {
            
$aValues mysql_fetch_array($oResult,MYSQL_ASSOC);
            
$sInfo $aValues['imagecount'];
        } else {
            
$sInfo "Error";
        }
    }
   
    
mysql_close($oLink);

    echo 
$sInfo;

?>
__________________
My Photoblog
If you find my help useful please consider feeding the PixelPost Kitty
If you're short on cash just feed my ego

Last edited by dakwegmo; 04-05-2007 at 03:45 PM.
Reply With Quote
  #34  
Old 04-05-2007, 03:33 PM
RAitch Offline
pixelpost guru
 
Join Date: Aug 2006
Location: Ontario
Posts: 115
I already made that change but didn't post it... just echoing the value. I didn't understand why the HTML code was required (borrowed starting point from another file).

I am echoing the result as mentioned and have tried the code as I've shown, but it doesn't work.

Is there something wrong with the include I have?


Don't worry, if I don't get it set as an addon... if I get this working I will post everything I did so somebody else can arrange it.
__________________
My Gallery
Reply With Quote
  #35  
Old 04-05-2007, 04:48 PM
dakwegmo's Avatar
dakwegmo+ Offline
Team Pixelpost
 
Join Date: Jul 2005
Location: West of Between
Posts: 689
What exactly doesn't work? I uploaded the files to my server and it seems to work fine.

I created one file called carousel.php that looks like this:
PHP Code:
<?php
   
    
//variable to hold count
    
$sInfo "";
   
    
//database information
    
$sDBServer "server";
    
$sDBName "pixelpost";
    
$sDBUsername "user";
    
$sDBPassword "password";

    
//create the SQL query string
    
$sQuery "Select count(*) as imagecount from pixelpost_pixelpost";
             
    
//make the database connection
    
$oLink mysql_connect($sDBServer,$sDBUsername,$sDBPassword);
    @
mysql_select_db($sDBName) or $sInfo "Unable to open database";
       
    if(
$sInfo == '') {
        if(
$oResult mysql_query($sQuery) and mysql_num_rows($oResult) > 0) {
            
$aValues mysql_fetch_array($oResult,MYSQL_ASSOC);
            
$sInfo $aValues['imagecount'];
        } else {
            
$sInfo "Error";
        }
    }
   
    
mysql_close($oLink);

    echo 
$sInfo;

?>
Then I created another file called test.php that looks like this:
PHP Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Carousel Test Page</title>
</head>

<body>
<script type="text/javascript">
var imagecount;
var pageLoad = function() {
    imagecount = <?php include("carousel.php"); ?>;

    var carousel = new YAHOO.extension.Carousel("mycarousel", 
        {
            numVisible:        7,
            animationSpeed:   .5,
            scrollInc:         7,
            navMargin:         40,
            autoplay:        10000,
            size:            imagecount,
            prevElement:     "prev-arrow",
            nextElement:     "next-arrow",
            prevButtonStateHandler:   handlePrevButtonState,
            nextButtonStateHandler:   handleNextButtonState
        }
    );
};

YAHOO.util.Event.addListener(window, 'load', pageLoad);

</script>
</body>
</html>
When I browse to test.php, I get a blank page, but viewing the source I see:
HTML Code:
<script type="text/javascript">
var imagecount;
var pageLoad = function() {
	imagecount = 82 ;

    var carousel = new YAHOO.extension.Carousel("mycarousel", 
82 happens to be the number of photos I have in my PP database, so the image count is getting from PHP to the JavaScript.
__________________
My Photoblog
If you find my help useful please consider feeding the PixelPost Kitty
If you're short on cash just feed my ego
Reply With Quote
  #36  
Old 08-13-2007, 09:44 PM
blinking8s's Avatar
blinking8s+ Offline
über loafer
 
Join Date: Oct 2004
Location: Bowling Green, Ky
Posts: 3,428
Send a message via ICQ to blinking8s Send a message via AIM to blinking8s Send a message via MSN to blinking8s Send a message via Skype™ to blinking8s
bump...
__________________
i should say more clever stuff
Reply With Quote
  #37  
Old 08-14-2007, 04:01 PM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
Here is my contribution to the challenge:
http://www.pixelpost.org/forum/showthread.php?t=7047
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
Reply With Quote
  #38  
Old 11-24-2007, 03:23 AM
RAitch Offline
pixelpost guru
 
Join Date: Aug 2006
Location: Ontario
Posts: 115
That's fabulous! Can't wait for the next versions. A piece of cake to implement, thanks for your efforts!

My implementation: http://seettl.com
__________________
My Gallery
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 12:21 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs