Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Help change $abspath_folder

    Hi,there
    Need to change this line :
    $abspath_folder = JPATH_BASE.DS.$folder;
    somehow to
    $abspath_folder = /public_html/mysite.com.$folder; or http://www.mysite.com.$folder;

    I tried
    $url=('http://www.mysite.com');
    $abspath_folder =$url.$folder;
    It dosn't work,
    Regards,
    Anton
    Here is my code:
    defined( '_JEXEC' ) or die( 'Restricted access' );

    class modBackgroundHelper
    {
    function getBackgroundImage(&$params)
    {
    // get the parameters
    $color = $params->get('color', '#ffffff');
    $image = $params->get('image');
    $random = $params->get('random');
    $folder = $params->get('folder', 'images/stories');
    $add_css = $params->get('additional_css');
    $idofbg = $params->get('idofbg');

    // prepare some variables
    $the_array = array();
    $the_image = array();

    //check the ID to add the background to, if nothing make body
    if ($idofbg == "") {
    $idofbg = "body";
    }

    // use random image
    if ($random == 1) {

    // if folder doesnt contain slash to start, add
    if ( strpos($folder, '/') !== 0 ) {
    $folder = '/'. $folder;
    }

    // construct absolute path to directory
    $abspath_folder = JPATH_BASE.DS.$folder;

    // check if directory exists
    if (is_dir($abspath_folder)) {
    if ($handle = opendir($abspath_folder)) {
    while (false !== ($file = readdir($handle))) {
    if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html' ) {
    $the_array[] = $file;
    }
    }
    }
    closedir($handle);

    foreach ($the_array as $img) {
    if (!is_dir($abspath_folder .'/'. $img)) {
    if (eregi('jpg', $img) || eregi('png', $img) || eregi('gif', $img) ) {
    $the_image[] = $img;
    }
    }
    }

    if (!$the_image) {
    return "No images";
    } else {
    $i = count($the_image);
    $random = mt_rand(0, $i - 1);
    $image = $the_image[$random];
    $abspath_image = $abspath_folder . '/'. $image;
    }
    }
    }
    // no random image
    else {
    $folder = "images/stories";
    }
    $livesite = JURI::base();

    // make the CSS output
    $output = "<style type=\"text/css\">" . $idofbg . " { background-color:" . $color . " !important;";
    if (!($image == -1 && random == 0)) {
    $output .= "background-image: url(" . $livesite . $folder . '/' . $image . ") !important;";
    // if add_css contains <br /> remove them
    if (stristr($add_css, '<br />') == TRUE) {
    $add_css = str_replace("<br />", "", $add_css);
    }
    $output .= $add_css;
    }
    $output .= " }</style>";

    // echo the CSS output
    return $output;
    }
    }

  • #2
    New Coder
    Join Date
    Mar 2010
    Location
    Virginia, USA
    Posts
    25
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Hello.

    Several options for you on this one.

    Code:
    $abspath_folder = "/public_html/mysite.com$folder";
    Code:
    $url='http://www.mysite.com';
    $abspath_folder = "$url$folder";
    Code:
    $url='http://www.mysite.com';
    $abspath_folder = $url . $folder;
    Hope it helps,
    - C. Aaron Smith


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •