Carousel with dynamic content - ajax

I came across a carousel from Twitter bootstrap here. http://twitter.github.com/bootstrap/javascript.html#carousel
It looks really good. But all the images / content in the example are hard-coded. How can I request the server for new content and show it in the carousel?

The answer would have to be adjusted for each language, but assuming you're programing in PHP, it may look something like this:
If you have an array of images:
$images = ['path/to/image.jpg', 'path/to/image2.jpg', 'path/to/image3.jpg']
Then you'd loop through those images, and place each one in the appropriate HTML markup, like so:
<?php foreach ($images as $image) { ?>
<div class="item">
<img src="<?php echo $image ?>" />
</div>
<?php } ?>

Related

Implementing a simple lightbox in Joomla 4

I am trying to transition to Joomla 4.
I have been using <?php JHTML::_('behavior.modal'); ?> in my index.php template.
Now I want to use <?php JHTML::_('bootstrap.renderModal', 'modal-' . $name, $params); ?>.
In the html of the articles, we used:
<a id="modal_info" class="modal" href="images/stories/hotel_suite1.jpg"><img style="width: 30%;" src="images/stories/hotel_suite1.jpg" alt="Null" /></a>
with various values for width and src. What do I change in my html? And I assume I need to add placeholders for $name and $params in my index.php. How do those get filled in realtime?

Unable to load image in symfony template +symonfy3.4

//index.html.php
<?php foreach ($view['assetic']->image(
array('#AppBundle/Resources/public/images/test.png')
) as $url): ?>
<div id="title">
<h1><a href="/home/#"><img alt="logo" src="<?php
echo $view->escape($url); ?>"> </a>
</h1>
</div>
<?php endforeach ?>
Above is my code in template after adding, I executed assetic:dump and it generated a images in web/images/ , still am not able to see images on my page. It is throwing 404 error for images.
Kindly let me know what going wrong here.
Note: Tried specifying image path in asset.yml and also LiipImagineBundle, nothing helped.
Assetics and assets are different.
do an bin/console assets:dump to put the resources of your bundle in the web directory then use your images like
<img src="<?php echo $view['assets']->getUrl('images/logo.png') ?>" />

Magento: how to display products on owl-carousel

I'm using magento 1.9.3 and I want to display featured products in home page in an owl carousel.
I have a method in the block of my module that returns me the collection I want to show in the carousel. I call it from my template like this:
$_productCollection=$this->getFeaturedProducts();
I found a previous question in stack overflow about this: Owl Carousel - Magento Products
and following this previous question I arrived to this in my template:
<div class="owl-carousel">
<?
$products = $this->getFeaturedProducts();
foreach ($products as $_product) { // iterate through the entire collection
echo '<div class="item"><img src='.$this->helper('catalog/image')->init($_product, 'small_image')->keepFrame(false)->resize($_imgSize).'></div>'; // print the image url inside of the required Owl markup
}
?>
</div>
But the div of owl-carousel is not displayed. If I inspect the page, the div is there, and the images inside too, but nothing is displayed. If I delete the owl-carousel class I see all the images displayed in list.
I installed the extension "Responsive Owl Slider" from magento connect, and I have another owl carousel on top of page made with the admin cms that shows image slides (not products) and it's working fine. The only one that fails is the one that I'm trying to do by code.
I see that the owl-carousel class has a display: none so obviously is not displaying anything, but if I delete the display: none it shows all the images at the same time, not a carousel.
How do I display my selected products in an owl carousel?
Please try this extension
https://www.magentocommerce.com/magento-connect/new-products-2.html
Hope it's helpful for you.
First go to the link >> https://magento.stackexchange.com/questions/83912/featured-products-on-homepage
Create all files to following answers.
Then open featured.phtml
copy and paste below code
<?php
$_helper = $this->helper('catalog/output');
$_productCollection = $this->getProductCollection();
?>
<div class="featured-products">
<ol class="featured-products-list owl-carousel" id="featured-products-list">
<?php foreach ($_productCollection as $_product): ?>
<li><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(200) ?>" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></li>
<?php endforeach; ?>
</ol>
</div>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".owl-carousel").owlCarousel();
});
</script>
Please don't forget create attribute and assign for products.

Joomla/Jomsocial PinMe template I want to replace the PinMe Avatar with JomSocial's Profile image

Hi I am using TemPlaza's PinMe template with the Jomsocial community component in Joomla! 3.0.3 Stable [ Ember ]
What I am looking for a very simple solution to having the Jomsocial avatar (Profile Image) replace the PinMe image on the Pins which
uses joomla core for image and profile
Jomsocial offers this:
Use JomSocial Avatars
To acquire a path to a JomSocial Avatar, you can simply request a cUser object and call a simple getThumbAvatar function to retrieve the avatar url.
include_once JPATH_ROOT.'/components/com_community/libraries/core.php';
// Get CUser object
$user = CFactory::getUser($userid);
$avatarUrl = $user->getThumbAvatar();
echo '<img src="'.$avatarUrl.'">';
The PinMe template is coded as such:
<?php if(isset($this->s_user) && $this->s_user==1){ ?>
<div class="TzAuthor">
<?php if(isset($Pins->user_img) && !empty($Pins->user_img)){ ?>
<img class="tz_pin_img_user" src="<?php echo JUri::root().'/'.$Pins->user_img; ?>">
<?php }else{ ?>
<img class="tz_pin_img_user" src="<?php echo JUri::root().'/components /com_tz_pinboard/images/avata.jpg'?>">
<?php }?>
<div class="TzAuthorInfo">
<a class="tz_pin_name_user"
href="<?php echo Route::_(TZ_PinboardHelperRoute::getPinboardManageruserRoute($Pins->id_user)); ?>" rel="nofollow">
<?php echo $Pins->user_name; ?>
<?php if(isset($Pins->name_user_repin) && !empty($Pins->name_user_repin)){
?>
<strong class="tz_by">
<?php echo JText::_('COM_TZ_PINBOARD_MANAGERUSER_REPIN_BY'); ?>
</strong>
<?php
echo $Pins->name_user_repin;
}
?>
</a>
spoke with the PinMe people and the cost for custom code isnt worth it and the sites on my local not live
to reiterate
all I am looking for a very simple solution to having the Jomsocial avatar (Profile Image) replace the PinMe profile image on the Pins
how do i make this happen

I have a script, in yii. That almost does the job, need just a little push

I am not a programmer by any means. I purchased the script and have spent two weeks and many variations trying to get the code to do what I need. It is 'almost' there.
<div id="step-2" style="position:absolute; center:overflow-y:;">
<?php if($images): ?>
<?php foreach ($images as $img => $data): ?>
<a href="javascript:;" class="pin-img">
<img src="<?php echo $img ?>" />
</div>
</a>
<?php endforeach; ?>
<?php else: ?>
<h2><?php echo Yii::t('yii', 'No relevant found!') ?></h2>
<?php endif ?>
</div>
It returns the images from a site. It only lets me select the first image. Even though all images are displayed. Only one is actually clickable. If I hover over each of the images I see the javascript href. I understand that to be some sort of place holder. that just makes the browser show the hand.
I just need the script to allow each item to be a choice for reaction.
http://silenceisnotawkward.com/Sinapin/Script/# is the live code.
I have made a test user
Test=user
Password =password in case anyone wants to see what the site does.
http://www.ew.com/ew/ is a good link to pin from website and see the behavior.
I didn't look at your site, but looks like you are confusing your nesting of HTML tags, because you introduced a end-of-dev tag in your link.
<div id="step-2" style="position:absolute; center:overflow-y:;">
<?php if($images): ?>
<?php foreach ($images as $img => $data): ?>
<a href="javascript:;" class="pin-img">
<img src="<?php echo $img ?>" />
<!-- I removed the < / div > from here -->
</a>
:
<?php endforeach; ?>
</div
>
HINT: I indented the code to make it more readable, Try doing the same with your code you posted and see where it leads you.

Resources