Custom Pages : added a function to get the images belonging to the current URL (or any other).

skala
jkbockstael 15 years ago
parent 51236ef53e
commit c1075c3623
  1. 2
      custompages/url-images/README
  2. 17
      main/inc/lib/custompages.lib.php

@ -1,3 +1,5 @@
Custom Pages : URL Images
This features allows each access URL to have a number of images (currently three) specific to this URL. This allows easier customization of landing pages by access URL.
You can access a URL's images by calling the static function CustomPages::getURLImages() in your custom page.

@ -3,6 +3,8 @@
// Used to implement the loading of custom pages
// 2011, Jean-Karim Bockstael <jeankarim@cblue.be>
require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php';
class CustomPages {
public static function displayPage($page_name) {
@ -16,5 +18,20 @@ class CustomPages {
error_log('CustomPages::displayPage : could not read file '.$file_name);
}
}
public static function getURLImages($url_id = null) {
if (is_null($url_id)) {
$url = 'http://'.$_SERVER['HTTP_HOST'].'/';
$url_id = UrlManager::get_url_id($url);
}
$url_images_dir = api_get_path(SYS_PATH).'custompages/url-images/';
$images = array();
for ($img_id = 1; $img_id <= 3; $img_id++) {
if (file_exists($url_images_dir.$url_id.'_url_image_'.$img_id.'.png')) {
$images[] = api_get_path(WEB_PATH).'custompages/url-images/'.$url_id.'_url_image_'.$img_id.'.png';
}
}
return $images;
}
}
?>

Loading…
Cancel
Save