Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #1  
Old 05-21-2009, 06:31 PM
Omar1000 Offline
pp regular
 
Join Date: May 2007
Posts: 27
insert php include in addon help

Maybe someone has an idea.

I am trying to build an addon, so far it is working, but the only problem:

include("get_resolution.php") in the script below is written into the top of my markup and I am not able to put it into the <head>-part with a TAG. I am not very good in PHP, any idea?

PHP Code:
if(preg_match("<BROWSER_SCRIPT>"$tpl)) {

$callget_res_page_name $REQUEST_URI;
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
$browser_script_out = include("get_resolution.php");

$tpl ereg_replace("<BROWSER_SCRIPT>",$browser_script_out,$tpl);

Reply With Quote
  #2  
Old 05-21-2009, 08:38 PM
Trauko's Avatar
Trauko Offline
pp veteran
 
Join Date: Sep 2006
Location: Dalcahue, Chiloé
Posts: 99
http://www.pixelpost.org/docs/Extend...ndingPixelpost

Suerte
Reply With Quote
  #3  
Old 05-22-2009, 04:49 PM
Omar1000 Offline
pp regular
 
Join Date: May 2007
Posts: 27
No solution

Sorry, but I can't find there a solution.

The variable $browser_script_out = include("file.php"); is not working like I want to. The include is writing a javascript to the image_template, but unfortunately as first entry, which is not usefull, I will let it write into that place I prefer (into <head>) with an PIXELPOST TAG.

I don't know how to get an include working. Or other question, is it possible to insert an include in general?
Reply With Quote
  #4  
Old 05-23-2009, 08:24 AM
Omar1000 Offline
pp regular
 
Join Date: May 2007
Posts: 27
How to get the browser size of the user?

May be I am to confused now, the reason why i want to solve this, I want to get the users browser size for delivering the depending image size.

I tried now several ways to get this script into the right position, but with no success.

I tried to put this in the addon, but this forces a loop:
PHP Code:
if(preg_match("<BROWSER_SCRIPT>"$tpl)) {

    
$callget_res_page_name $REQUEST_URI;
    
$GLOBALS[callget_res_page_name] = $callget_res_page_name;
        
function 
showScript(){
    include_once(
"get_resolution.php");
    return(
$screen_width);
    }
$browser_script_out showScript();
$tpl str_replace("<BROWSER_SCRIPT>",$browser_script_out,$tpl); 


this is my get_resolution.php:
PHP Code:
<script language="javascript">
<!--
function writeCookie() 
{
 var today = new Date();
 var the_date = new Date("December 31, 2023");
 var the_cookie_date = the_date.toGMTString();
 var the_cookie = "users_res="+ window.innerWidth +"x"+ window.innerHeight;
 var the_cookie = the_cookie + ";expires=" + the_cookie_date;
 document.cookie=the_cookie
 if (document.cookie){  
    location = '<?=$GLOBALS[callget_res_page_name]?>';
 }
 
}


function checkRes(width, height) {
    if(width != window.innerWidth || height != window.innerHeight) {
        writeCookie();
    } else {
        return true;
    }
}
//-->
</script>

<?
if(isset($HTTP_COOKIE_VARS["users_res"])) {
    
$screen_res $HTTP_COOKIE_VARS["users_res"];
    
$screen_res_tmp explode("x"$screen_res);
    
$screen_width $screen_res_tmp[0];
    
$screen_height $screen_res_tmp[1];
    
?>
    <script language="javascript">
    <!--
    checkRes(<?=$screen_width?><?=$screen_height?>);
    //-->
    </script>
    <?
}
else 
//means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
//-->
</script>

<?
}
?>
if anybody knows a way how to get this solved I really appreciate. May be there is a better solution to get the browser size of the user?
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 08:43 AM.

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