I am a beginner programmer so I do not master certain parts very well.
I developed a joomla module that allows you to display an accordion menu according to the level you entered in the admin interface for my company's website. My module is made of a php file containing also the style part and the script (the links to the Jquery scripts) and an XML file.
My problem is that as soon as I try to add on the same page 2 articles using the same module the page just crash and I don't know why, is there any kind soul that could help me to figure out what is the problem please ?
(also it's my first time using Stack Overflow I'm sorry if I am using it in a wrong way)
Here is my code (without the database connexion and the whole path to the script) :
<?php
//space dedicated to the connexion to the database
$idMod=$module->id; //Idendifiant du module a intéger en cas de script dans le nom des paramètres
$id.$idMod=$params->get('base'); //We retrieve the parameters
//We check to connexion
if($mysqli->connect_error){
die('Erreur : ' .$conn->connect_error);
}
function HasChildAccordion($mysqli, $Num, $idModule){ //lets you know if there are children for the associated menu
$Nbenfant.$idMod=0;
$Enfant.$idMod= "SELECT id FROM sgc_menu WHERE parent_id=$Num AND published=1";
$exec=mysqli_query($mysqli, $Enfant.$idMod);
while($result=mysqli_fetch_array($exec, MYSQLI_ASSOC)){
$Nbenfant.$idMod= $Nbenfant.$idMod+1;
}
$Nbenfants.$idMod=$Nbenfant.$idMod;
return $Nbenfants.$idMod;
}
function getChildAccordion($mysqli, $bla, $idModule){ //Recursive function to display menu names and retrieve submenus
$query.$idMod="SELECT link, title, level, parent_id, id FROM sgc_menu WHERE id=$bla AND published=1";
$exec=mysqli_query($mysqli, $query.$idMod);
while ($TOTO = mysqli_fetch_assoc($exec)) {
$test=HasChildAccordion($mysqli, $TOTO['id'], $idMod);
if ( $test!=0){
//echo '<a class="myNav-link ui-accordion-trigger'.$idMod.'" href="'.$TOTO['link'].'">'.$TOTO['title'].'</a>';
echo '<a class="myNav-link ui-accordion-trigger" href="'.$TOTO['link'].'">'.$TOTO['title'].'</a>';
// echo '<div class="myNav-content ui-accordion-content'.$idMod.'">' ;
echo '<div class="myNav-content ui-accordion-content">' ;
$query2="SELECT id, title, level, parent_id, link FROM sgc_menu WHERE parent_id=$bla AND published=1";//On récupères les enfants
$exec2=mysqli_query($mysqli, $query2);
while($result=mysqli_fetch_array($exec2, MYSQLI_ASSOC)){ // For every children we apply the function getChildAccordion;
// echo '<div class="subNav ui-accordion'.$idMod.'">';
echo '<div class="subNav ui-accordion">';
getChildAccordion($mysqli, $result['id'], $idMod); //we display children's children
echo '</div>' ;
}
echo '</div>' ;
} else {
//echo '<div class="myNav-item ui-accordion-item'.$idMod.'">';
echo '<div class="myNav-item ui-accordion-item">';
echo '<a class="clicable" href="'.$TOTO['link'].'">'.$TOTO['title'].'</a>';
echo '</div>';
}
}
// $Nbenfant=0;
}
//echo '<div class="myNav ui-accordion'.$idMod.'">';
echo '<div class="myNav ui-accordion">';
getChildAccordion($mysqli, $id.$idMod, $idMod); //the function is called with the menu chosen in the configuration of the module
echo '</div>';
?>
<script src="http://.../jquery.min.js"></script>
<script src="http://.../jquery.simpleAccordion.min.js"></script>
<script>
$(document).ready(function() {
$('.ui-accordion').simpleAccordion ({
item :'.ui-accordion-item',
trigger :'.ui-accordion-trigger',
content :'.ui-accordion-content',
active :'active',
autoclose:true,
multiple :true,
speed:500 });
});
$(document).ready(function() {
$('.SubNav').simpleAccordion ({
trigger :'.subui-accordion-trigger',
content :'.subui-accordion-content',
active:'active',
autoclose:true,
multiple:true,
speed:1000});
});
</script>
//
<style>
<?php
$colorbg=$params->get('colorbg');
$colortext=$params->get('colortext');
$colorHover=$params->get('colorHover');
$FontSize=$params->get('FontSize');
$colortextClickable=$params->get('colortextClickable');
?>
.myNav {
position: static;
display:block;
background-color: <?php echo $colorbg ; ?>;
padding:2% 2% 2% 2%;
margin: 2% 2% 2% 5%;
border-radius: 4px;
border: 1px solid #1c4281;
margin: 5px 22px 18px 22px;
padding-top: 10px;
box-shadow: 7px 7px 5px 0px rgba(28, 66, 129, 0.75);
font-family: Kepler_296;
}
.myNav a{
position : static;
display:inline;
color:<?php echo $colortext ; ?>;
font-family: Kepler_296;
}
.myNav-item:not(:first-child) {
border-top:1px solid #fff;
}
.myNav-link {
position:static;
display:block;
}
.myNav-content {
position:static;
display:block;
padding:2% 2% 2% 2%;
margin: 2% 2% 2% 2%;
}
.subNav{
justify-content:space-around;
}
.ui-accordion-content, .subui-accordion-content{ display:none; }
.active > .ui-accordion-content, .active> .subui-accordion-content {
display:block;
}
a.clicable {
color:<?php echo $colortextClickable ; ?>;
font-family: Kepler_296;
font-size: <?php echo $FontSize ; ?>px;
}
a.clicable:hover{
color:<?php echo $colorHover ; ?>;
font-weight: bold;
}
.ui-accordion-trigger{
font-size: <?php echo $FontSize ; ?>px;
cursor:pointer;
position: static;
display: inline;
}
.ui-accordion-trigger::after {
margin: -15px 0px 0px 2px;
content:'\1F892';
position:static;
display: inline;
float:right;
top:50%;
font-size: 40px;
transition-duration: 0.5s;
}
.active> .ui-accordion-trigger::after{
margin: -15px 0px 0px 20px;
position: static;
display: inline;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
transition-duration: 0.8s;
}
</style>
I thought the problem came from a variable but I sincerly have no idea
I cannot debug the whole thing.
But here's a couple of things I noticed:
$query.$idMod =
is a funny way to put the sql into $idMod. And it does nothing to $query. Also, it is beyond confusing.
What you wanted to achieve is most likely to declare a different variable name for your query for each instance of the module.
This would be achieved with:
${'query'.$idMod} =
but you don't need it. Most likely, the cause for the module content repeating is the cache, try disabling it.
Finally, you might want to look into css variables, the stylesheet you pasted would benefit from using them.
Related
Im currently using laravel 9, laravel dompdf package for export my file , this the pdf file igot , no content at all. the data i pass did not display in the PDF. ::
But when I just open it as view , the data pass properly and the css work nice. This is how it looks like :
Here is my code on the View:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
</head>
<style>
* {
box-sizing: border-box;
margin:0;
padding:0;
}
body {
background:#DDD;
}
div.container {
max-width: 1350px;
margin: 0 auto;
overflow: hidden
}
.upcomming {
font-size: 45px;
text-transform: uppercase;
border-left: 14px solid rgba(255, 235, 59, 0.78);
padding-left: 12px;
margin: 18px 8px;
}
.container .item {
width: 48%;
float: left;
padding: 0 20px;
background: #fff;
overflow: hidden;
margin: 10px
}
.container .item-right, .container .item-left {
float: left;
padding: 20px
}
.container .item-right {
padding: 79px 0px;
margin-right: 20px;
width: 25%;
position: relative;
height: 286px;
text-align: center;
}
.container .item-right .up-border, .container .item-right .down-border {
padding: 14px 15px;
background-color: #ddd;
border-radius: 50%;
position: absolute
}
.container .item-right .up-border {
top: -8px;
right: -35px;
}
.container .item-right .down-border {
bottom: -13px;
right: -35px;
}
.container .item-right .num {
font-size: 50px;
color: #111
}
.container .item-right .day, .container .item-left .event {
color: #555;
font-size: 15px;
margin-bottom: 9px;
}
.container .item-right .day {
text-align: center;
font-size: 25px;
}
.container .item-left {
width: 71%;
padding: 34px 0px 19px 46px;
border-left: 3px dotted #999;
}
.container .item-left .title {
color: #111;
font-size: 34px;
margin-bottom: 12px
}
.container .item-left .sce {
margin-top: 5px;
display: block
}
.container .item-left .sce .icon, .container .item-left .sce p,
.container .item-left .loc .icon, .container .item-left .loc p{
float: left;
word-spacing: 5px;
letter-spacing: 1px;
color: #888;
margin-bottom: 10px;
}
.container .item-left .sce .icon, .container .item-left .loc .icon {
margin-right: 10px;
font-size: 20px;
color: #666
}
.container .item-left .loc {display: block}
.fix {clear: both}
.container .item .tickets, .booked, .cancel{
color: #fff;
padding: 6px 14px;
float: right;
margin-top: 10px;
font-size: 18px;
border: none;
cursor: pointer
}
.container .item .tickets {background: #777}
.container .item .booked {background: #3D71E9}
.container .item .cancel {background: #DF5454}
.linethrough {text-decoration: line-through}
</style>
<body>
<div class="container">
<h1 class="upcomming">Event Tickets</h1>
#php ($i=1)
#foreach ($tickets as $key=> $ticket)
<div class="item">
<div class="item-right">
<h2 class="num"> {{ $ticket->ticket_no }}</h2>
<p class="day">Ticket No.</p>
<span class="up-border"></span>
<span class="down-border"></span>
</div> <!-- end item-right -->
<div class="item-left">
<p class="event">{{ $ticket->GiftGiving->name }}</p>
<h2 class="title">{{ $ticket->name }}</h2>
<div class="sce">
<p>{{Carbon\Carbon::parse($ticket->GiftGiving->start_at )->isoFormat('LL') }}<br/> {{ Carbon\Carbon::parse($ticket->GiftGiving->start_at )->isoFormat('h:mm A') }}</p>
</div>
<div class="fix"></div>
<div class="loc">
<p>{{ $ticket->GiftGiving->venue }}</p>
</div>
<div class="fix"></div>
<button class="booked">Batch No. {{ $ticket->GiftGiving->batch_no}}</button>
</div> <!-- end item-right -->
</div> <!-- end item -->
<!--Set limitation of printing only 5 ticket per page-->
#if ($i % 6 === 0)
<div style="page-break-after: always;"></div>
#endif
#php ($i++)
#endforeach
</div>
</body>
</html>
Controller
public function GenerateTicket($code)
{
# Retrieve the records using $code
$GiftGiving = GiftGiving::where('code', $code)->firstOrFail();
$tickets = GiftGivingBeneficiary::where('gift_giving_id', $GiftGiving->id)->get();
# Users can only access their own charity's records
if ($GiftGiving->charitable_organization_id == Auth::user()->charitable_organization_id) {
# Must have at least one beneficiary before generating tickets
if ($tickets->count() < 1) {
$toastr = array(
'message' => 'Gift Giving must have at least one (1) beneficiary first before generating tickets',
'alert-type' => 'error'
);
return redirect()->back()->with($toastr);
}
# Retrieve the last batch no. from the gift giving.
$batch_no = $GiftGiving->batch_no;
# Increment Batch no. by +1
$GiftGiving->update([
'last_downloaded_by' => Auth::id(),
'batch_no' => $batch_no + 1,
]);
# Audit Logs Creation
$log = new AuditLog;
$log->user_id = Auth::user()->id;
$log->action_type = 'GENERATE PDF';
$log->charitable_organization_id = Auth::user()->charitable_organization_id;
$log->table_name = 'Gift Giving';
$log->record_id = $GiftGiving->code;
$log->action = 'Charity Admin generated tickets for the Gift Giving [' . $GiftGiving->name . '] with batch no. ' . $GiftGiving->batch_no . '.';
$log->performed_at = Carbon::now();
$log->save();
# Send Notification to each user in their Charitable Organizations
$users = User::where('charitable_organization_id', Auth::user()->charitable_organization_id)->where('status', 'Active')->get();
foreach ($users as $user) {
$notif = new Notification;
$notif->code = Str::uuid()->toString();
$notif->user_id = $user->id;
$notif->category = 'Gift Giving';
$notif->subject = 'Generated Tickets';
$notif->message = Auth::user()->role . ' ' . Auth::user()->info->first_name . ' ' .
Auth::user()->info->last_name . ' has generated tickets for [' . $GiftGiving->name . '] with batch no. ' .
$GiftGiving->batch_no . '.';
$notif->icon = 'mdi mdi-ticket';
$notif->color = 'info';
$notif->created_at = Carbon::now();
$notif->save();
}
// return view('charity.gifts.generate_ticket', compact('tickets'));
$pdf = PDF::loadView('charity.gifts.generate_ticket', compact('tickets'));
return $pdf->download($GiftGiving->name . ' - No. ' . $GiftGiving->batch_no . '.pdf');
} else {
$toastr = array(
'message' => 'Users can only access their own charity records.',
'alert-type' => 'error'
);
return redirect()->back()->with($toastr);
}
}
Hope somebody can point out what did i miss, thankyou in advance . all suggest/answer are highly appreciated.
dompdf is really picky about CSS and styles... but first, you should always put your <style> tags inside the <head> tag of the document. Without putting it there, there will be inconsistencies in how different browsers render the content, and that includes headless systems and domPDF.
So put your <style> tag in the <head> tags, and see if that helps resolve the issue, and if not, try converting your styles to tables with styling, as dompdf seems to do better with tables than divs.
you should care about syntax:
#php $i = 1; #endphp
#php $i++; #endphp
I am creating a stylesheet for print media that includes an inline SVG as the content of an element's pseudo-class (i.e., ::before, ::after).
When testing in Chrome, it seems to work just fine, but when the page is first loaded in Firefox and Safari, the SVG element does not appear in the print preview. It then appears on all subsequent attempts.
I am not exactly sure what is going on, but if I had to guess, my conjecture would be: when page hasn't been cached there is latency rendering the pseudo-element that is happening concurrently to the browser creating the print page.
I am very curious to know why this is happening, and if there is any solution where an SVG pseudo-element can be used reliably.
Here is a stripped down code example. Please see if you can reproduce this issue:
var button = document.querySelector('button');
button.addEventListener('click', function () {
window.print();
});
div {
text-align: center;
}
button {
margin: 2em;
padding: 1em 2em;
}
#media print {
button {
display: none;
}
div::before {
content: 'Pseudo-elements';
font-weight: bold;
margin-top: 1em;
}
div::after {
position: relative;
display: block;
margin-top: 1em;
content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><circle cx='50' cy='50' r='50' /></svg>");
}
}
<div>
<button>
print
</button>
</div>
I can repro.
It seems to be a bug with the loading of the svg, I guess it would be the same with any image.
One workaround is to load it outside of your #print rules with display: none :
var button = document.querySelector('button');
button.addEventListener('click', function() {
window.print();
});
div {
text-align: center;
}
button {
margin: 2em;
padding: 1em 2em;
}
div::after {
display: none;
content: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><circle cx='50' cy='50' r='50' /></svg>");
}
#media print {
button {
display: none;
}
div::before {
content: 'Pseudo-elements';
font-weight: bold;
margin-top: 1em;
}
div::after {
opacity: 1;
position: relative;
display: block;
margin-top: 1em;
}
}
<div>
<button>
print
</button>
</div>
An other one would be to preload it via js before hand.
I'm experimenting with Wordpress and (the recent version of) dompdf at the moment and ran into an annoying problem regarding the formating.
My Problem: The top-margin of the main content seems not to be considered on the second page generated, resulting in an overlapping with my logo. You can view the generated PDF under this link.
The relevant code from which the PDF is generated reads as follows (it is not perfect yet as i want to resolve the issue first):
function ppt_pdf_output() {
// post-ID of referring page needed
$post=get_post($_POST['postid']);
$output = '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>'.$post->post_title.'</title>
<style>
body {
margin: 30px 0 0 0;
font-family:sans-serif;
text-align:left;
}
img {
margin: 15px 0;
}
#header,
#footer {
position: fixed;
left: 0;
right: 0;
color: #aaa;
font-size: 0.9em;
line-height:1.2em;
}
#header {
top: -30px;
/*border-bottom: 0.1pt solid #aaa;*/
}
#footer {
bottom: 0;
border-top: 0.1pt solid #aaa;
}
#header table,
#footer table {
width: 100%;
border-collapse: collapse;
border: none;
text-align: center;
color: #000;
font-size: 24px;
}
.entry-content {
margin: 100px auto 35px auto;
top: 0; left: 0; bottom: 0; right: 0;
background-color: #d1d977;
width:90%; height:auto;
}
.entry-title {
font-size: 18px;
text-align: center;
}
#header td,
#footer td {
padding: 0;
width: 50%;
}
#footer .page-number {
text-align: center;
}
.page-number:before {
content: "Seite " counter(page);
}
.gallery-item {
display:inline-block;
}
br[style] {
display:none;
}
.gallery + p {
clear:left;
}
</style>
</head>
<body><div id="header">
<table>
<tr>
<td>ANTRAG</td>
<td style="text-align: right;"><img src="path/to/logo.png" /></td>
</tr>
</table>
</div>
<div id="footer">
<div class="page-number"></div>
</div>';
$output .='
<!--<h1 class="entry-title">'. $post->post_title .'</h1>-->
<div class="entry-content">' .
apply_filters('the_content',$post->post_content) . '</div>';
$output .= '</body></html>';
return $output;
}
As you can see, the formatting on the first page is as it should be (or at least as I intended it to be), but after the page break the content area (for visualization reasons provided with a green background) just starts at the beginning of the page, regardless of which number I give the margin.
Has anybody an idea how to resolve this issue? I've been working on this for countless hours and just don't know what to do at this point.
Any help would be greatly appreciated.
Kind regards
Olli
UPDATE: Of course I found this solution only just. I will try this and see if I can get the issue resolved with this.
UPDATE2: Still no luck. I'm now stuck with the following code (the output can be found under the link provided earlier):
function ppt_pdf_output() {
// post-ID of referring page needed
$post=get_post($_POST['postid']);
$output = '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>'.$post->post_title.'</title>
<style>
#page {
margin: 120px 50px 80px 50px;}
#header {
position: fixed;
top: -82px;
width: 100%;
height: 109px;
background: #aaa url("path/to/logo.png") no-repeat right;
}
#content {
width: 100%;
height: 85%;
background-color: #d1d977;
}
footer {
position: fixed;
bottom: -65px;
height: 30px;
background-color: #333399;
}
footer .page-number {
text-align: center;
}
.page-number:before {
content: "Seite " counter(page);
}
br[style] {
display:none;
}
</style>
</head>
<body><div id="header">
<h2>ANTRAG</h2>
</div>
<footer>
<div class="page-number"></div>
</footer>';
$output .='<h1>'. $post->post_title .'</h1>
<div id="content">' .
apply_filters('the_content',$post->post_content) . '</div>';
$output .= '</body></html>';
return $output;
}
It seems just so fragile. For example, as soon as I change the font-size of the h1 element, it gets overlapped by the logo. After the page break, it looks okay, but that just seems an coincidence - as soon as I change the font-size or the text, the text again gets overlapped. Will absolute positioning change anything or do you have any other tipps as how to resolve this anoying issue? Margins of any kind don't seem to work either.
You're on the right track. As you've seen, when an element is split across pages (as your content area is) some of the formatting information does not follow. This is by design.
The correct tact is to define the page margins so that they are large enough to hold your header/footer content and place the header/footer into that space. The content will then just fill the "body" of the document (i.e. the space inside the page margins). This is what you've attempted, but you haven't given enough space for the header. The header is positioned 82px inside the page margin but the height of the header is 109px. Because of this any content that has a small margin will still fall under the header.
Try this instead:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>"Kaffeefahrten" in Bornheim: hart durchgreifen, Senioren vor Betrügern schützen</title>
<style>
#page {
margin: 120px 50px 80px 50px;
}
#header {
position: fixed;
top: -115px;
width: 100%;
height: 109px;
background: #aaa url("path/to/logo.png") no-repeat right;
}
#content {
background-color: #d1d977;
}
footer {
position: fixed;
bottom: -65px;
height: 30px;
background-color: #333399;
}
footer .page-number {
text-align: center;
}
.page-number:before {
content: "Seite " counter(page);
}
br[style] {
display:none;
}
</style>
</head>
<body>
<div id="header">
<h2>ANTRAG</h2>
</div>
<footer>
<div class="page-number"></div>
</footer>
<h1>"Kaffeefahrten" in Bornheim: hart durchgreifen, Senioren vor Betrügern schützen</h1>
<div id="content">
...
</div>
</body>
</html>
Note that you also don't have to specify any height/width for the content element (unless you want to further constrict the space it uses).
With CSS3 you could go with your original styling and re-use the margins by applying the box-decoration-break property. However as of writing dompdf does not yet support this property.
I am trying to use the background-size property in IE8 with this promising solution: https://github.com/louisremi/background-size-polyfill
But I am getting this error: SCRIPT65535: Unexpected call to method or property access.
Any ideas or alternatives to set the image size of a background-image in IE8?
It might be worth noting that the polyfill isn't designed to work with specific pixel sizes, i.e. background-size: 32px 64px
I know this doesn't answer your question, but for IE 8, I've just been removing non-important backgrounds with this CSS hack (instead of trying to figure out how to size them)
background: none\9;
try this css code, ie8 working dropshadow
body {
margin: 0;
background: url(images/algeria.jpg) center no-repeat;
-ms-behavior: url(backgroundsize.min.htc);
}
.bgsCover {
background-size: cover;
}
.bgsContain {
background-size: contain;
}
/* this allows to use a second background in all browsers and IE8 */
body:after {
content: "";
background: url(images/pattern.png) repeat;
position: absolute;
z-index: -1;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
/* responsive carousel FTW */
#carousel {
height: 45%;
width: 50%;
margin: 0 auto;
background: #0F0808;
border-radius: 3px;
}
#carousel ul {
height: 100%;
padding: 0;
margin: 0;
list-style: none;
}
#carousel li {
display: none;
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: contain;
-ms-behavior: url(backgroundsize.min.htc);
}
#carousel .active {
display: block;
}
/* less interesting stuff below */
html, body {
height: 100%;
font-family: "Arial", "Liberation Sans", sans-serif;
color: #FEE;
}
h1 {
font-family: 'Great Vibes', sans-serif;
text-align: center;
margin: 0 0 40px;
text-shadow: 0 0 2px #222;
font-size: 1.7em;
font-weight: normal;
position: relative;
top: 20px;
filter: progid:DXImageTransform.Microsoft.Shadow(color=#222222, direction=90);
}
h1 i {
font-size: 1.3em;
display: block;
-moz-transform: rotate(-15deg);
-webkit-transform: rotate(-15deg);
-o-transform: rotate(-15deg);
-ms-transform: rotate(-15deg);
transform: rotate(-15deg);
filter: progid:DXImageTransform.Microsoft.Shadow(color=#222222, direction=90);
}
p {
text-align: center;
font-size: 1.5em;
text-shadow: 0 0 2px #222;
/* For IE 8 */
filter: progid:DXImageTransform.Microsoft.Shadow(color=#222222, direction=90);
/* For IE 5.5 - 7 */
zoom: 1;
color: #CCC
}
.button {
color: #0F0808;
text-decoration: none;
background: #FEE;
border-radius: 3px;
text-shadow: none;
padding: 4px 8px;
}
Your HTML Source code
<body class="bgsCover">
<h1><i>background-size</i> polyfill</h1>
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png" alt="Fork me on GitHub">
<div id="carousel">
<ul>
<li id="img1" class="active" style="background-image: url(images/algerian1.jpg);">
<li id="img2" style="background-image: url(images/jar1.jpg);">
<li id="img3" style="background-image: url(images/algerian2.jpg);">
<li id="img4" style="background-image: url(images/jar2.jpg);">
</ul>
</div>
<p>Stretch background image using CSS3 <code>background-size: cover;</code> and <code>background-size: contain;</code>, in IE8 too.<br/>
Reacts to resize events for responsive backgrounds and galeries!</p>
<p><a class="button" href="https://github.com/louisremi/background-size-polyfill#readme">Instructions</a> - <a class="button" href="https://github.com/louisremi/background-size-polyfill/downloads">Downloads</a></p>
<script>
/*var images = [
'algeria.jpg',
'parthenon.jpg',
'propylaea.jpg'
],
curImg = 0;
document.getElementById("switchImage").onclick = function() {
curImg = ( curImg + 1 ) % images.length;
document.body.style.backgroundImage = "url(images/" + images[ curImg ] + ")";
};
var sizes = [
"Cover",
"Contain",
"Auto"
],
curSize = 0;
document.getElementById("switchSize").onclick = function() {
curSize = ( curSize + 1 ) % sizes.length;
document.body.className = "bgs" + sizes[ curSize ];
};*/
var items = document.querySelectorAll("#carousel li"),
curItem = 0;
setInterval(function() {
items[ curItem ].className = "";
curItem = ( curItem + 1 ) % items.length;
items[ curItem ].className = "active";
}, 3000);
</script>
</body>
i got the same issue on IE8. When i copied ".htaccess" in root folder. It works perfectly.
The Polyfill did not work for me either. My solution was to use the original "deprecated" version.
<!--[if lt IE 9]>
<script
src="//louisremi.github.io/jquery.backgroundSize.js/jquery.backgroundSize.js">
</script>
<script>
$('.logo').css( "background-size", "cover" );
</script>
<![endif]-->
Actually the deprecated version is not necesary.
For me it worked when I used behavior instead of -ms-behavior
I am using the wordpress plugin WP Featured Content Slider which uses the jquery.cycle.all.2.72.js. I am getting a really bizarre visual glitch. On page load, all the slides are shown on top of each other, then as the script cycles through each slide, sometimes it eventually fixes itself (until the page is reloaded).
I found another topic on this forum with the same problem and solution listed jQuery Cycle Slides overlap on page load
But I am not a technical person..can someone tell me where i need to put the codes suggested in the above solution in a wordpress self hosted blog.
Find the example here http://ramblingego.com
The Content Slider PHP Code is as below
<?php
$direct_path = get_bloginfo('wpurl')."/wp-content/plugins/wp-featured-content-slider";
?>
<script type="text/javascript">
jQuery('#featured_slider ul').cycle({
fx: '<?php $effect = get_option('effect'); if(!empty($effect)) {echo $effect;} else {echo "scrollLeft";}?>',
prev: '.feat_prev',
next: '.feat_next',
speed: 800,
timeout: <?php $timeout = get_option('timeout'); if(!empty($timeout)) {echo $timeout;} else {echo 4000;}?>,
pager: null
});
</script>
<style>
#featured_slider {
float: left;
margin: 10px 0px;
position: relative;
background-color: #<?php $bg = get_option('feat_bg'); if(!empty($bg)) {echo $bg;} else {echo "FFF";}?>;
border: 1px solid #<?php $border = get_option('feat_border'); if(!empty($border)) {echo $border;} else {echo "CCC";}?>;
width: <?php $width = get_option('feat_width'); if(!empty($width)) {echo $width;} else {echo "860";}?>px;
}
#featured_slider ul, #featured_slider ul li {
list-style: none !important;
border: none !important;
float: left;
margin: 10px;
width: <?php $width = get_option('feat_width'); if(!empty($width)) {echo $width;} else {echo "860";}?>px;
height: <?php $height = get_option('feat_height'); if(!empty($height)) {echo $height;} else {echo "210";}?>px;
}
#featured_slider .img_right {
float: left;
width: <?php $img_width = get_option('img_width'); if(!empty($img_width)) {echo $img_width;} else {echo "320";}?>px;
height: <?php $img_height = get_option('img_height'); if(!empty($img_height)) {echo $img_height;} else {echo "200";}?>px;
margin-left: 20px;
}
#featured_slider .img_right img {
width: <?php $img_width = get_option('img_width'); if(!empty($img_width)) {echo $img_width;} else {echo "320";}?>px;
height: <?php $img_height = get_option('img_height'); if(!empty($img_height)) {echo $img_height;} else {echo "200";}?>px;
}
#featured_slider .content_left {
float: left;
color: #<?php $text_color = get_option('text_color'); if(!empty($text_color)) {echo $text_color;} else {echo "333";}?>;
width: <?php $text_width = get_option('text_width'); if(!empty($text_width)) {echo $text_width;} else {echo "450";}?>px;
}
#featured_slider .content_left p {
line-height: 22px !important;
color: #<?php $text_color = get_option('text_color'); if(!empty($text_color)) {echo $text_color;} else {echo "333";}?>;
}
#featured_slider .content_left h2 {
font-size: 20px !important;
margin-bottom: 20px;
}
#featured_slider .feat_prev {
background: transparent url(<?php echo $direct_path;?>/images/sprite.png) no-repeat;
background-position: 0px 0px;
width: 17px;
z-index: 10;
height: 16px;
position: absolute;
left: 20px;
cursor: pointer;
bottom: 30px;
float: left;
}
#featured_slider .feat_prev:hover {
background-position: 0px -16px;
}
#featured_slider .feat_next {
background: transparent url(<?php echo $direct_path;?>/images/sprite.png) no-repeat;
background-position: -17px 0px;
width: 17px;
z-index: 10;
height: 16px;
position: absolute;
left: 40px;
bottom: 30px;
cursor: pointer;
}
#featured_slider .feat_next:hover {
background-position: -18px -16px;
}
</style>
<div id="featured_slider">
<ul id="slider">
<?php
$sort = get_option('sort'); if(empty($sort)){$sort = "post_date";}
$order = get_option('order'); if(empty($order)){$order = "DESC";}
$limit = get_option('limit'); if(empty($limit)){$limit = 350;}
$points = get_option('points'); if(empty($points)){$points = "...";}
$post_limit = get_option('limit_posts'); if(empty($limit_posts)){$limit_posts = "-1";}
global $wpdb;
global $post;
$args = array( 'meta_key' => 'feat_slider', 'meta_value'=> '1', 'suppress_filters' => 0, 'post_type' => array('post', 'page'), 'orderby' => $sort, 'order' => $order, 'numberposts'=> $post_limit);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
$custom = get_post_custom($post->ID);
$thumb = get_wp_generated_thumb("feat_slider");
?>
<li><div class="content_left"><h2><?php the_title();?></h2><?php echo cut_text_feat(get_the_content(), $limit, $points);?></div><div class="img_right"><img src="<?php echo $thumb;?>" /></div></li>
<?php endforeach; ?>
</ul>
<div class="feat_next"></div>
<div class="feat_prev"></div>
</div>
If you can't output all the slides with display:hidden you can use jquery to hide all of them (except the first one) and then the cycle plugin should do the rest.
Like this:
<script type="text/javascript">
jQuery('#featured_slider ul>li:gt(0)').hide(function() {
jQuery('#featured_slider ul').cycle({
fx: '<?php $effect = get_option('effect'); if(!empty($effect)) {echo $effect;} else {echo "scrollLeft";}?>',
prev: '.feat_prev',
next: '.feat_next',
speed: 800,
timeout: <?php $timeout = get_option('timeout'); if(!empty($timeout)) {echo $timeout;} else {echo 4000;}?>,
pager: null
});
});