WebsiteBaker Support (2.8.x) > Templates, Menus & Design
Bs_naturak - wrong slider images on corresponding pages
jacobi22:
i can say now: read my post, every needed information is there :wink:
TEMPLATE_DIR is the complete URL to the active frontend-Template, but
MEDIA_DIRECTORY is only the name of the folder "media", you need the complete URL, like
--- Quote ---$slider_image_base = WB_URL.MEDIA_DIRECTORY.'/slide'
--- End quote ---
if you like a subdirectury in your media-folder, maybe called "my_slides", the URL to the pics must be
--- Quote ---$slider_image_base = WB_URL.MEDIA_DIRECT ORY.'/my_slides/slide'
--- End quote ---
if this path is not correct or the called pictures doesnt exist, it look's like the slider is not implemented on this or on all pages
your code and $p_id
$page_id is a fix variable with the ID from the actual page, come's from the core.
$p_id is only needed in the file snippets/responsive-slider.php to build the links, do not change $page_id in the index.php of the template
use in the next line $page_id again, because $p_id is not defined and it show's the slider on every page
--- Quote ---if (!isset($page_id) OR $page_id==4 OR $page_id==4) {
--- End quote ---
if (!isset.... means: if the variable between () is not avaiable on this point
without ! like
if (isset.... means: if the variable between () avaiable on this point - (not used here)
the first OR $page_id==4 means together with the first part: if we have not defined a Page-ID or the Page-ID (from the actual page) is 4
the second OR $page_id==4 is not needed, if its means the same Page-ID like the first question, its only neeeded for different Page-ID's
--- Quote ---if (!isset($page_id) OR $page_id==4 OR $page_id==6) {
--- End quote ---
All this together means
if we have no page_id or i am on the page with ID=4 or on page with ID = 6 , please show the slider
and after the }else{
on the page with ID=4 or on page with ID = 6 show no slider
jacobi22:
example for the case "show the slider not on Page with ID=4 or ID=6, but on all other pages
if ($page_id != 4 OR $page_id != 6) {
include('snippets/responsiveslides.php');
include('snippets/nav.php');
include('snippets/site-headline.php');
} else {
include('snippets/miniheader.php');
include('snippets/nav.php');
}
include('snippets/playground.php');
include('snippets/2col-content.php');
elfinlay:
Thank you so much for this comprehensive reply, jacobi22!
--- Quote ---Quote
$slider_image_base = WB_URL.MEDIA_DIRECT ORY.'/my_slides/slide'
if this path is not correct or the called pictures doesnt exist, it look's like the slider is not implemented on this or on all pages
--- End quote ---
I have followed all of your instructions. The images are appearing on the slider with the call to $slider_image_base = WB_URL.MEDIA_DIRECT ORY.'/my_slides/slide'. However, they are not appearing at all on the individual pages.
Since I only want the slider to appear on page 24 or 2, I have used the following code, based on your instructions:
--- Code: ---if (!isset($page_id) OR $page_id==24 OR $page_id==2) {
include('snippets/responsiveslides.php');
include('snippets/nav.php');
include('snippets/site-headline.php');
} else {
include('snippets/miniheader.php');
include('snippets/nav.php');
}
include('snippets/playground.php');
include('snippets/2col-content.php');
--- End code ---
Sincere thanks, again!
elfinlay:
Hello again.
It seems that the slider is now linked to the WB_URL.MEDIA_DIRECT ORY, and drawing on the photos from there.
However, the static images on the other pages are still being taken from TEMPLATE_DIR/img.
If I change the numbers on slide1.jpg, slide2.jpg and slide3.jpg around, I can get them to match the images on the slide this way.
However, this means that if others want to change the images through the media folder using the backend, I would still have to add them to the templates/img folder via ftp.
I can't work out how to link the non-slider pages to the images in the media directory.
Once again, any advice would be greatly appreciated. Happy to post more code if needed.
jacobi22:
maybe, we have some problem's to understand us :oops: :wink:
i use google translate for your postings and my own bad english for my answer's :oops:
1. it is recommended to use a folder inside of the WB-System for your pics. (but its also possible to use picture from other sources)
2. the advantage of the wb-media-directory is: you can change pics or upload new pics without a ftp-program, you need only WB-Media-Administration, but it works also, if the pics stored in the template like the original template-code
3. Choose a place for the pic's - wb-media-directory or template-directory, it doesnt matter, where, but you need for this 2 cases two different solutions. My personal opinion is a separat folder for the sliderpics in one of this directorys
I fear that you're a bit confused because of all my postings :oops:
if you want, zip your template and posted here or via email (we or i need only your index.php of this template and the file snippets/responsiveslides.php
choose a favorite directory (doesnt matter, where) and tell me the used slider pic names and the wished Page-ID's, where the slider is to be visible
i'sure, it only a little error and if you want to try it yourself....
the index.php tell the file snippets/responsiveslides.php only the directory of the slider-pics and the begin of the picture name here in this line
(search in your index.php for the word "$slider_image_base")
$slider_image_base = WB_URL.MEDIA_DIRECT ORY.'/slider/slide';
the code in the bottom of the index.php is only the switch for the slider to show it on different places. it has nothing to do with the picture path.
all the picture-handling is in the file snippets/responsiveslides.php
the first part of this file snippets/responsiveslides.php build the sliderbox and has also nothing to do with the picture path
Line 34 startet a mysql request to read information about the pages, defined in index.php from the template
the important line for your problems are here (original-code from the template
--- Quote ---while($page = $query_pages->fetchRow()) {
$i++;
$page_id = $page['page_id'];
$nr = $page_id; //Use $page_id OR $i for picture numbers. $i (1, 2, 3...) is easier to handle, $page_id is mor specific.
//Start output:
$l = '
<li><img class="img-responsive" src="'.$slider_image_base.$nr.'.jpg" alt="'.$page['menu_title'].'">
--- End quote ---
$i++ is a intern counter for this while-loop
$page_id = $page['page_id'] - set the readed page_id from the database to the variable, called $page_id
$nr = $page_id - see the comment, here you can switch between $i (numered pictured, starting with 1) and $page_id (picture has the page_id from the wished page in the end. these are the here defined pages -> $slider_page_ids = '2,14,18';
the last line of this posted code is the picture link. important is this part here
src="'.$slider_image_base.$nr.'.jpg"
$slider_image_base is the definition from the index.php of the template
$nr is the number from the intern counter or the page_id from the page in this loop
its important, to go only one way in this handle - using the counter or using the specific page id. my favorite is the specific page_id, because, i know directly in the directory, for which page is this image
if i use the intern counter, i have to think around corners :wink:
i'm sure, the error is inside my posted code lines
its recommened, not overwrite the WB-variable for the page_id (see post from fischstäbchenbrenne r at the begin of this thread), so a better solution is a own variable name
here the complete code with this changes for the file snippets/responsiveslides.php (must work!)
--- Code: ---<?php if(!defined('WB_URL')) { header('Location: ../../../index.php'); exit(0); } ?>
<!-- banner -->
<div class="banner">
<!-- slider -->
<!-- img-slider -->
<div class="img-slider">
<!--start-slider-script-->
<script src="<?php echo TEMPLATE_DIR; ?>/js/responsiveslides.min.js"></script>
<script>
$(function () {
// Slideshow 4
$("#slider4").responsiveSlides({
auto: true,
pager: true,
nav: true,
speed: 500,
namespace: "callbacks",
before: function () {
$('.events').append("<li>before event fired.</li>");
},
after: function () {
$('.events').append("<li>after event fired.</li>");
}
});
});
</script>
<!-- End-slider-script-->
<!-- Slideshow 4 -->
<div id="top" class="callbacks_container">
<ul class="rslides" id="slider4">
<?php
$theq = "SELECT * FROM `".TABLE_PREFIX."pages` WHERE page_id IN (".$slider_page_ids.");" ;
$query_pages = $database->query($theq);
if($query_pages->numRows() < 1) {
//do nothing
} else {
$i = 0;
while($page = $query_pages->fetchRow()) {
$i++;
$new_page_id = $page['page_id'];
$nr = $new_page_id; //Use $new_page_id OR $i for picture numbers. $i (1, 2, 3...) is easier to handle, $new_page_id is mor specific.
//Start output:
$l = '
<li><img class="img-responsive" src="'.$slider_image_base.$nr.'.jpg" alt="'.$page['menu_title'].'">
<div class="slider-caption"><h1>'.$page['page_title'].'</h1><p>'.$page['description'].'</p>';
$l .= '<a class="caption-btn" href="'.WB_URL.PAGES_DIRECTORY.$page['link'].PAGE_EXTENSION.'">'.$TEXT['READ_MORE'].'</a>';
$l .= '</div></li>';
echo $l;
}
}
?>
</ul> </div>
<div class="clearfix"> </div>
</div><!-- slider -->
</div><!-- end banner -->
--- End code ---
and now, you need only the correct path in the index.php from the template like
stored pics directly in media-directory
--- Code: ---$slider_image_base = WB_URL.MEDIA_DIRECTORY.'/slide'
--- End code ---
or
stored pics in a subfolder calles "sliderpics" in media-directory
--- Code: ---$slider_image_base = WB_URL.MEDIA_DIRECTORY.'/sliderpics/slide'
--- End code ---
or
stored pics directly in template-folder
--- Code: ---$slider_image_base = TEMPLATE_DIR.'/slide'
--- End code ---
or
stored pics in a subfolder calles "sliderpics" in template directory
--- Code: ---$slider_image_base = TEMPLATE_DIR.'/sliderpics/slide'
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version