Hi I'm using this plugin called Meta Slider light and what I am trying to accomplish is getting the <li> to call the class of the image id.
Each Image has an ID and It calls the ID in the Img class but I want it to call it in the <li> class.
Below is the source code.
https://github.com/mihadaiko/ml-slider/blob/master/inc/slide/metaslide.image.class.php
on line 215 this code
'class' => "slider-{$this->slider->ID} slide-{$this->slide->ID}",
that code gives me this --> <img src="img url" class="slider-ID slide-ID">
The class calls for the Slider ID and The slide id.
and on line 347 it calls the <li> element.
$html = '<li style="display: none;"' . $thumb . '>' . $html . '</li>';
Each image is wrappen in an <li> element.
which gives me this
<li style="display:none;"><img src="img url"> class="slider-ID slide-ID"></li>
What I want to do is add the class line to the <li> element.
So far I have tried this
$html = '<li style="display: none;" class="slide-{$this->slide->ID}" ' . $thumb . '>' . $html . '</li>';
and it is still not working, it's calling the actual code instead of the image id. What am I doing wrong.
The value in there is most likely escaped before being printed. This means that your PHP is never given the chance to evaluate before being output on the page. I could be wrong, but it looks that way.
Try this instead
'class' => "slider-" . $this->slider->ID . " slide-" . $this->slide->ID,
edit, this
$html = '<li style="display: none;" class="slide-'. $this->slide->ID .'" ' . $thumb . '>' . $html . '</li>';
Related
I am trying to show a advanced custom fields data in previous post link in wordpress. But The data is not showing also it breaks the html as well.
<div class="prev-posts pull-left">
<?php
$prev_post = get_previous_post();
if($prev_post) {
$prev_title = strip_tags(str_replace('"', '', $prev_post->post_title));
echo "\t" . '<a rel="prev" href="' . get_permalink($prev_post->ID) . '" title="' . $prev_title. '" class=" ">
<strong>
<<< "'. $prev_title . '"
</strong>
<img src="'.the_field("girl_image").'" alt="'.the_title().'/>
</a>' . "\n";
}
?>
</div>
In this code the "girl_img" field contains the URL of an image. I want to show the image based on the URL. But it is showing the URL itself instead of showing the image.
Use get_field() instead of the_field().
get_field() = Returns the value of the specified field.
the_field() = Displays the value of the specified field. This function is the same as echo get_field($field_name);
Replace the_field("girl_image") with get_field("girl_image")
I'm trying to make a userfeed for the homepage of my website that displays new information from users, for example: user x just did somthing.
This is what it looks like sofar: Image of page
this is the code used on the page:
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
echo '
<div class="media testimonial-inner">
<div class="pull-left">
<img class="img-responsive img-square" src="images/bierportaal.jpg" height="66" width="66">
</div>
<div class="media-body">
<span><a href="' . $row["naam"] . '"target=main>' . $row["naam"] . '</a></span>
<span>' . $row["tekst_before"] . '</span><a href="' . $row["item"] . '"target=main>' . $row["item"] . '</a>
<span>' . $row["tekst_after"] . '</span>
</div>
</div>
';
}
} else {
}
$db_conx->close();
?>
My question is, How do I rotate trough the activities?
So that when someone does somthing (it will be inserted into the database)the records jump and the top one will display a new record and the bottom one wil move out of the screen/disapear.
An example of what i have in mind is on this website the activetyfeed:
ratebeer website
Kind regards,
Aerosteon
Hey guys got a question on outputting a dynamic PHP block for a dynamically created PHP page. In my code I am looking for a string in an HTML page thats been uploaded. Once found I am replacing the string with a block of PHP code, the HTML page will be saved as a PHP page to be used on the project. So as I am looping through the HTML I am replacing the string with this ($i is replaced with the number in the loop so I can use them in my array.)
$phpCodeNoLink = '<span id="Title'.$i.'"><?php echo $sl_result['.$i.'][2]; ?></span>
<a href="editor.php?<?php echo "vfSID=" . $sl_result['.$i.'][0] . "&vfSection=2&vfSLink=" . $sl_result['.$i.'][4] . "&vfOrderID=" . $sl_result['.$i.'][5] . "&vfID=" . $vfID; ?>" target="_parent">
<img src="images/btn_edit.gif" border="0" id="SL_editButton'.$i.'" class="editButton" />
</a>';
The problem is it is not outputting what I need, example of what it should look like
<span id="Title1"><?php echo $sl_result[1][2]; ?></span>
<a href="editor.php?<?php echo "vfSID=" . $sl_result[1][0] . "&vfSection=2&vfSLink=" . $sl_result[1][4] . "&vfOrderID=" . $sl_result[1][5] . "&vfID=" . $vfID; ?>" target="_parent">
<img src="images/btn_edit.gif" border="0" id="SL_editButton1" class="editButton" />
</a>
This is what I get in the PHP page once it's generated
<span id="Title0"><?php echo $sl_result[0][2]; ?></span>
<a href="editor.php?<?php%20echo%20%20" vfsid=" . $sl_result[0][0] . " .>" target="_parent">
<img src="images/btn_edit.gif" border="0" class="editButton"></a>
The PHP tags are being replaced and I am missing a whole block of code. Am I missing something any help would be much appreciated.
Figured it out, the PHP code was being parsed and removed by my inline CSS converter moving it above all the other parsing resolved it issue...
I'd like to show the first 5 names in a list and toggle the display of any additional names as a single block.
I've currently got the names list as an array object though I'm happy to change it to an array if the solution would be simpler with that.
Here's what I have so far which is *in*complete because I don't know how to create the hidden div of names:
PHP
$names_count=0;
echo '<div id='nameList' class='toggler'>';
foreach($names as $name){
echo '<a id='name'.$name->acct_id.'>'.$name->full_name.'</a>';
if($names_count<=4){
echo '</div><!--toggler div-->';
}
else
<div class='namesList' style='display:none'>
//put additional names in hidden div?
</div>
}
$names_count++;
} //endforeach
JS:
UPDATE Sorry for the confusion. This isn't really a javascript question so I deleted that tag but I'm including the following jQuery code snippet for completeness with the PHP
$('.toggler').click(function(){
var id=this.id;
$('#'+id).toggle();
});
PHP
$names_count = 0;
echo '<div id="nameList" class="toggler">';
foreach($names as $name) {
echo '<a id="name' . $name->acct_id . '">' . $name->full_name . '</a>';
if ($names_count == 4) {
echo '</div><div class="hidden">';
}
$names_count++;
}
echo '</div>';
JS
$('.toggler').click(function(){
$(this).next().toggle();
});
CSS
.hidden {
display: none;
}
Here's an example with two while loops.
$names = array('Bob', 'Andy', 'Tim', 'Max', 'Roger', 'John', 'Test');
$nameCount = count($names);
$nameIndex = 0;
echo '<div id="nameList" class="toggler">';
// Show the first 5 names.
while ($nameIndex < min(5, $nameCount)) {
$name = $names[$nameIndex++];
echo '<a id="name' . $name . '">' . $name . '</a>';
}
// Show the remaining names in a hidden div.
if ($nameIndex < $nameCount)
{
echo '<div class="hiddenNames" style="display:none">';
while ($nameIndex < $nameCount) {
$name = $names[$nameIndex++];
echo '<a id="name' . $name . '">' . $name . '</a>';
}
echo '</div>';
}
echo "</div>";
That code produces the following output.
<div id="nameList" class="toggler">
<a id="nameBob">Bob</a>
<a id="nameAndy">Andy</a>
<a id="nameTim">Tim</a>
<a id="nameMax">Max</a>
<a id="nameRoger">Roger</a>
<div class="hiddenNames" style="display:none">
<a id="nameJohn">John</a>
<a id="nameTest">Test</a>
</div>
</div>
It also safe if you have less than 5 names; the script would produce :
<div id="nameList" class="toggler">
<a id="nameBob">Bob</a>
<a id="nameAndy">Andy</a>
<a id="nameTim">Tim</a>
</div>
For the JS, I would probably do something along the lines of :
$('.toggler').click(function(){
$('.hiddenNames').toggle();
});
Even if the code is a bigger, I find it easier to follow and probably easier to maintain in the long run. (Opinion)
Hope this helps!
To make a <div> hidden:
<div style="display: hidden"></div>
Then the jQuery should make it visible with the .toggle() command.
I'm using FancyBox to contain my iframes, but it only works for the first array. Here's what the array looks like:
$gallery_items = array(
array("img_src" => "gallery/thumb_1.jpg", "link" => "gallery/profile1.txt"),
array("img_src" => "gallery/thumb_2.jpg", "link" => "gallery/profile2.txt"),
and so on, and then here is how it is produced:
echo '<li><a id="various3" href ="' . $current_gallery_item["link"] . '"><img src="' . $current_gallery_item["img_src"] . '" /></a></li>';
the id="various3" is how FancyBox tells its an iframe. But, it only works for the first array.
Revised answer:
It seems you don't want iFrames but just load the content via Ajax. Your problem is that every element has the same ID. If you attach Fancybox via
$('#various3').fancybox();
then it will only be applied to the first element, because IDs have to be unique.
Use classes instead:
<ul>
<?php foreach($gallery_items as $item): ?>
<li>
<a class="various3" href ="<?php echo $item['link']; ?>">
<img src="<?php echo $item["img_src"]; ?>" />
</a>
</li>
<?php endforeach;?>
</ul>
And jQuery:
$('a.various3').fancybox();
If you really want to have iFrames, you can just add the iframe class to the link elements:
<a class="various3 iframe" ...>
This will automatically tell Fancybox to use iFrames.
See also Fancybox - How to use.
foreach($gallery_items as $current_gallery_item){
echo '<li><a id="various3" href ="' . $current_gallery_item["link"] .
'"><img src="' . $current_gallery_item["img_src"] . '" /></a></li>';
}
Might work
You used the same id (namely, "various3") for several elements.
This will not work this way.
Every id should be unique.
assign some class to A-tags and use it:
$("#various3")
--->
$(".various3")