hello friends I am newbie to YII. I have an image . After calling that image in Yii its code like is this
<img class="deals_product_image" src="<?php echo MPFunctions::uploaded_image_url($data->item_display_image()->file_ufilename); ?>" alt="<?php echo $data->name; ?>" />
in general html it is doing like this
<img alt="women jackets" src="files/items/images/4db3b3b6a7c06/womens-jacket-thumb.jpg" class="deals_product_image">
Now I want that this image should be a href link like
<a href="files/items/images/4db3b3b6a7c06/womens-jacket-thumb.jpg img src="files/items/images/4db3b3b6a7c06/womens-jacket-thumb.jpg class="deals_product_image"/> </a>
so for this I used code like this
<?php echo CHtml::link('', array('items/viewslug', 'slug'=>$data->slug)); ?>
But it is not showing any link tag like <a href="">
so can any one tell me what should I do?What should I write in between '' tags?
You should simply give the html for the <img> tag as the first parameter:
$imageUrl = MPFunctions::uploaded_image_url($data->item_display_image()->file_ufilename);
$image = '<img class="deals_product_image" src="'.$imageUrl.'" alt="'.$data->name.'" />';
echo CHtml::link($image, array('items/viewslug', 'slug'=>$data->slug));
By the way, you can use CHtml::image to create the <img> tag as well:
$imageUrl = MPFunctions::uploaded_image_url($data->item_display_image()->file_ufilename);
$image = CHtml::image($imageUrl, $data->name, array('class' => 'deals_product_image'));
echo CHtml::link($image, array('items/viewslug', 'slug'=>$data->slug));
Related
I'm using slick carousel and I'm faced with the problem of having multiple rows only on specific columns. Is it possible to do this with slick carousel?
I'm trying to replicate this carousel layout:
As we can see from the image above, this carousel's first and last images are straightforward. However, when we look at the second and third carousel items, we can see these images are in multiple rows.
I understand that slick carousel has a rows function such as this example, but is it possible to only have this feature only for specific columns? If not, would you guys know any other way to accomplish this task?
For context, I'm using the ACF Gallery field (WordPress) to put in the images and using its loop to parse out the images in the front-end like this:
<div class="gallery-carousel">
<?php $index = 1; ?>
<?php foreach( $images as $image ): ?>
<div>
<img
src="<?php echo esc_url($image['url']); ?>"
alt="<?php echo esc_attr($image['alt']); ?>"
/>
<?php echo $index; ?>
</div>
<?php $index++; ?>
<?php endforeach; ?>
</div>
Thank you for your help!
I'm new here and I'm writing my first php code. I want to prepare a multiple choice quiz in which, after click on a button at the end of the page, the radios button (the choices of the test) will remain checked and unchangeable. I simplify the code in this way:
<?php
$choice1 = "a";
$choice2 = "b";
?>
<form method="post" name="testForm" id="testForm">
<ul>
<li><input type="radio" name="q1" value="a"
<?php if(isset($_POST['test-result']) && $radioVal==$choice1){ echo "disabled='disabled' checked";}?>
<?php if(isset($_POST['test-result']) && $radioVal<>$choice1){ echo "disabled='disabled'";}?>>
<?php echo "<span id='question'>". $choice1 ."</span>";?> </li>
<li><input type="radio" name="q1" value="b"
<?php if(isset($_POST['test-result']) && $radioVal==$choice2){ echo "disabled='disabled' checked";}?>
<?php if(isset($_POST['test-result']) && $radioVal<>$choice2){ echo "disabled='disabled'";}?>>
<?php echo "<span id='question'>". $choice2 ."</span>";?> </li>
</ul><br>
<button class='button' name='test-result'>Finaliza el test</button>
</form>
<?php
if (isset($_POST['test-result']))
{
$radioVal = $_POST["q1"];
}
?>
However, after click on the button, all radios remain uncheged (and this is ok) but the choices made are not checked. Can someone help me? Thanks in advance!
Checkbox is not showing checked because variable $radioVal is set after input box. To resolve your issue could you please set $radioVal before from.
I am facing a problem with showing the recently viewed products in my product page.
Here is my local.xml code:
<catalog_product_view translate="label"> reference name="root"> <action method="setTemplate">page/1column.phtml <block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed" template="reports/product_viewed.phtml"/></block></reference>
Here is my footer.phtml code:
<div class="footer-container">
<div class="footer">
<?php $maniPage = $this->getUrl('');
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
$url = Mage::getSingleton('core/url')->parseUrl($currentUrl);
if ($maniPage == $currentUrl){
echo $this->takeCategory(12,1) /*12 = brands category 1 = show images*/ ;
}
?>
<div class="block-content">
<?php echo $this->getChildHtml('product_recently_viewed') ?>
</div>.....
Here is my product_viewed.phtml (standard file from core)
<?php if ($_products = $this->getRecentlyViewedProducts()): ?>
<div class="block block-list block-viewed">
<div class="block-title">
<strong><span><?php echo $this->__('Recently Viewed Products') ?></span></strong>
</div>
<div class="block-content">
<ol id="recently-viewed-items">
<?php foreach ($_products as $_item): ?>
<li class="item">
<p class="product-name"><?php echo $this->helper('catalog/output')->productAttribute($_item, $_item->getName() , 'name') ?></p>
</li>
<?php endforeach; ?>
</ol>
<script type="text/javascript">decorateList('recently-viewed-items');</script>
</div>
</div>
<?php endif; ?>
When I inspect the elements, the from the footer is empty. All files posted are in my theme. I have my own css so may be it won't be shown as expected, but at least the div should have any data inside, right? Could you please help me with this one. Thank you in advance.
I'm using Colorbox in form of Yii 1.x widget. Everything works fine, except for the fact, that Colorbox does not group my images and does not show <-- / --> buttons.
This is part of code generated by my page:
<div class="media-gallery-wrapper">
<div class="media-gallery-item">
<a href="http://127.0.0.1/usrector/htdocs/uploads/galleries/15.jpg" class="colorbox cboxElement" title="">
<img src="http://127.0.0.1/usrector/htdocs/uploads/galleries/15small.jpg" alt="" width="450" height="450">
</a>
</div>
</div>
Each three of such blocks are followed by:
<div class="media-gallery-separator"></div>
And that's all. Even though I've been trying to modify my code and browsing through Colorbox examples, I don't see any significant difference between my code and those on examples. Thus, I don't know, what makes my Colorbox not grouping images?
Grouping in Colorbox works only, if you base it on rel attribute. You can't use classes.
So, this:
<a href="<?php echo $filename; ?>" class="colorbox" title="<?php echo $title; ?>">
<script type="text/javascript">
jQuery('.colorbox').colorbox({'maxHeight':'80%','maxWidth':'90%'});
</script>
won't work (no image grouping, no <- / -> buttons), while this:
<a href="<?php echo $filename; ?>" rel="colorbox" title="<?php echo $title; ?>">
<script type="text/javascript">
jQuery('a[rel="colorbox"]').colorbox({'maxHeight':'80%','maxWidth':'90%'});
</script>
will work like a charm.
I'm working on learning about Instagram's API as a side project. I've followed this tutorial (http://eduvoyage.com/instagram-search-app.html) to implement a search feature by hashtag. It was extremely helpful to me. One of the things I saw in the API was the location ID feature, and I was wondering how to implement that. Through a search on this site, I found that a request can be made which will return the following.
'{
"meta": {
"code": 200
},
"data": {
"attribution": null,
"tags": [],
"type": "image",
"location": {
"latitude": 48.8635,
"longitude": 2.301333333
},
"comments": {
"count": 0,
"data": []
},
..........'
I'm trying to figure out this tutorial to process that information. (http://www.ibm.com/developerworks/xml/library/x-instagram1/index.html#retrievedetails)
<html>
<head>
<style>
</head>
<body>
<h1>Instagram Image Detail</h1>
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Http_Client');
// define consumer key and secret
// available from Instagram API console
$CLIENT_ID = 'YOUR-CLIENT-ID';
$CLIENT_SECRET = 'YOUR-CLIENT-SECRET';
try {
// define image id
$image = '338314508721867526';
// initialize client
$client = new Zend_Http_Client('https://api.instagram.com/v1/media/' . $image);
$client->setParameterGet('client_id', $CLIENT_ID);
// get image metadata
$response = $client->request();
$result = json_decode($response->getBody());
// display image data
?>
<div id="container">
<div id="info">
<h2>Meta</h2>
<strong>Date: </strong>
<?php echo date('d M Y h:i:s', $result->data->created_time); ?>
<br/>
<strong>Creator: </strong>
<?php echo $result->data->user->username; ?>
(<?php echo !empty($result->data->user->full_name) ?
$result->data->user->full_name : 'Not specified'; ?>)
<br/>
<strong>Location: </strong>
<?php echo !is_null($result->data->location) ?
$result->data->location->latitude . ',' .
$result->data->location->longitude : 'Not specified'; ?>
<br/>
<strong>Filter: </strong>
<?php echo $result->data->filter; ?>
<br/>
<strong>Comments: </strong>
<?php echo $result->data->comments->count; ?>
<br/>
<strong>Likes: </strong>
<?php echo $result->data->likes->count; ?>
<br/>
<strong>Resolution: </strong>
<a href="<?php echo $result->data->images
->standard_resolution->url; ?>">Standard</a> |
<a href="<?php echo $result->data->images
->thumbnail->url; ?>">Thumbnail</a>
<br/>
<strong>Tags: </strong>
<?php echo implode(',', $result->data->tags); ?>
<br/>
</div>
<div id="image">
<h2>Image</h2>
<img src="<?php echo $result->data->images
->low_resolution->url; ?>" /></a>
</div>
<div id="comments">
<?php if ($result->data->comments->count > 0): ?>
<h2>Comments</h2>
<ul>
<?php foreach ($result->data->comments->data as $c): ?>
<div class="item"><img src="<?php echo $c
->from->profile_picture; ?>" class="profile" />
<?php echo $c->text; ?> <br/>
By <em> <?php echo $c->from->username; ?></em>
on <?php echo date('d M Y h:i:s', $c->created_time); ?>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
<?php
} catch (Exception $e) {
echo 'ERROR: ' . $e->getMessage() . print_r($client);
exit;
}
?>
</body>
</html>
The main problem (I think) that I'm having is here:
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Http_Client');
I downloaded Zend Frame 1.12.13, but I'm not sure what these line of code is asking for. In the Zend Framework folder, It goes "Zend/Loader(Folder)", but nothing called "Loader.php". Does that just load everything in the 'Loader' folder? Same for the Zend_Loader, there is a directory of Zend/Http/Client, but Client is also a folder.
tl;dr
Trying to set up a program that will search instagram (as linked in the tutorial above), be able to click on the picture results, open one tab that shows the picture and the users profile, and another tab that shows all the image metadata. Is there a simpler way to do this? Or a more noob friendly tutorial?
I ran into a similar problem when using this example. You must include the path of the Zend framework at the very top of this example. I did it in just its own php block at the top.
ini_set('include_path', 'path/to/ZendFramework/library');