How to use Microdata for URLs in Joomla? - joomla

I read here about Microdata in Joomla. However, I'm not able to produce a link with Microdata.
I want a Microdata output like:
<a itemprop="url" href="http://someurl">
<span itemprop="name">Some Url</span>
</a>
I want a link to an organisation from my client's website. My code is:
$microdata = new JMicrodata('Organization');
<div <?php echo $microdata->displayScope();?>>
echo $microdata->content( $this->item->url )->property( 'sameAs' )->display();
// outputs <span itemprop="sameAs">www.url_of_company.com</span>
</div>
Both url and sameAs Schema.org properties are of type URL, as per my understanding.
I also tried to wrap it with an anchor tag but Joomla is not producing itemprop along with href attribute in anchor tag.
I must be missing something.

Ok I analysed in libraries/joomla/microdata/microdata.php the method display();
and it doesn't exist any way to produce a <a href="#" > tag, only div, span and meta.
Btw there is a static method called htmlProperty(), with that you can add the property you need.
<?php $microdata = new JMicrodata('Organization'); ?>
<div <?php echo $microdata->displayScope(); ?> >
<a <?php echo JMicrodata::htmlProperty('url'); ?> href="http://google.com">
<?php echo $microdata->content('Google')->property('name')->display(); ?>
</a>
</div>

Related

Display comment regarding posts

I am developing a blog using codeigniter, every thing works good like posts are being stored comments are being made likes also works the only problem is fetching the comments using codeigniter against each post. What i want to do is that i want to send id to controller of each id when page loads. Here is the screenshot to make it more clear how i am working.
Front end is like this
Now the code section:
1. Code on the blog page where all messages and posts are being shown
<div class="col-lg-11 col-md-10 col-sm-10 col-xs-9 post_message" id="getComments<?php echo $blog -> blog_id; ?>">
<p>
<?php echo $blog -> message; ?>
</p>
<span class="pull-left">
<small> Posted By: <?php echo $blog -> name; ?></small>
</span>
<!-- onclick="get_comments(this.id, '<?php //echo base_url('users/get_comments_total'); ?>')" id="<?php// echo $blog -> blog_id; ?>-->
<a>
<i class='fa fa-comment' aria-hidden='true'></i> Comments (<small> <?php echo $rows; ?> </small>)
</a>
<a onclick="update_like('<?php echo $blog -> blog_id; ?>', '<?php echo base_url('users/update_like'); ?>')">
<i class='fa fa-thumbs-up' aria-hidden='true'></i> Likes (<small><?php echo $blog -> likes; ?></small>)
</a>
<div class="result_id<?php echo $blog -> blog_id; ?>" style="display: block;float: left;width: 100%;"></div>
</div> <!-- End of post message -->
In the above code there is a line written in comments where on-click function is defined i want to pass each id on page load to controller instead of click and all this code is written in foreach loop.
Help me with this thing or tell if there is any better idea to achieve this. Please do see the image attached with this so that you can know easily how i want to display the comments. one hint is like FB comments.
What is $rows?
If the likes are working OK then you can use the same idea for the comments. Probably you have joined the likes table and that is why you have $blog -> likes;. You should join the comments table to the query and then use Comments (<small> <?php echo $blog->comments; ?> </small>).
If this does not work you should provide your query in the model and your database structure.

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.

How do I add pages to menu?

I am new to Magento; now I am trying to develop a simple example site.
My question is this: how can we add pages to main menu?
create one static block with "Your page name"
Create new category with display mode "Static block only" and "include in navigation menu = YES" and select your cms block and save category. And see in front-end side this will be added in navigation item.
Here is the official Magento recommendation on how to do this: http://www.magentocommerce.com/knowledge-base/entry/adding-page-links-in-the-navigation-bar
To add a CMS page link to top navigation the hard way, you should override /mnt/www/x1886/app/design/frontend/default/default/template/catalog/navigation/top.phtml.
There are plenty tutorials out there about how to override files in Magento.
Change a change where I placed a comment:
<div class="header-nav-container">
<div class="header-nav">
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
<ul id="nav">
<!-- ADD ADDITIONAL LINKS HERE -->
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
<?php echo $this->getChildHtml('topLeftLinks') ?>
</div>

Show a single image based on product Id

I've created a module to show YouTube videos on a CMS page in Magento by pasting the videoId into a text field for each product, the video then shows on each custom CMS product page. The problem I have now is I need to pull a single image for the 'Play' button which is the logo for each product but I am not sure how to this.
I've tried creating another attribute called videothumbnail and selecting media image bot I can't see the field in the manage products section so I am a bit stuck.
This is the code that shows the YouTube video for each page. You will se that the image I currently have will show on all CMS page even if they are different products I need to assign an image to each page if possible.
<?php $_product = Mage::getModel('catalog/product')->load($this->getProductId()); ?>
<?php if ($_product->getId() && $_product->getVideoid()): ?>
<ul class="list">
<h3 class="product-name">Video</h3>
<li> <a class="fancybox-video" href="http://www.youtube.com/embed/<?php echo $_product->getVideoid(); ?>">
<img src="<?php echo $this->getSkinUrl('images/x5-play.png');?>" /></a> </li>
</ul>
<?php endif;?>
Assuming that you create a new media image called videothumbnail
By going to Admin -> Catalog -> Attribute -> Manage Attribute
Then create a new attribute of 'Media Image' for 'Catalog Input Type for Store Owner'
Then add it to a 'Manage Attribute Sets' in Admin -> Catalog -> Attribute
(you may need to do a reindex to catalog flat table)
<?php $_product = Mage::getModel('catalog/product')->load($this->getProductId()); ?>
<?php if ($_product->getId() && $_product->getVideoid()): ?>
<ul class="list">
<h3 class="product-name">X5 Mop Video</h3>
<li>
<a class="fancybox-video" href="http://www.youtube.com/embed/<?php echo $_product->getVideoid(); ?>">
$_helper = Mage::helper('catalog/output');
$_img = '<img id="image" src="' . Mage::helper('catalog/image')->init($_product, 'videothumbnail')->resize(410,420) . '" width="410" height="420" />';
echo $_helper->productAttribute($_product, $_img, 'image');
</li>
</ul>
<?php endif;?>
For less faff, but less control, you can pull a live thumbnail from YouTube very easily if you have the video ID:
How do I get a YouTube video thumbnail from the YouTube API?
You should consider using this as a fallback for if the product has no Magento video thumbnail specified.

magento: how to show custom attributes from general tab in front page automatically

when we upload one product, there is a default attribute set "Default", and in the general tab, there are many default attributes like below image:
well, i added one more custom attribute named "size", when i drag 'size' to general tab on the left, that mean the product has one more attribute. if i want to show the size attribute in the product view page of front end page, i have to put the code: "$_product->getAttributeText('size')", if i added lots of custom attributes, i have to put lots of codes manually. so, my question is how i can show all custom attributes automatically instead of adding one by one manually ?
This is allready done by magento.
Mark your attributes as vissible in frontend and thats it.
Have a look at the template attributes.phtml in path app/design/frontend/yourtheme/default/template/catalog/product/view
<?php if($_additional = $this->getAdditionalData()): ?>
<!--h2><?php echo $this->__('Additional Information') ?></h2-->
<div class="data-table accordion" id="product-attribute-specs-table">
<?php foreach ($_additional as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
<div class="clearer <?php echo $this->htmlEscape($this->__($_data['label'])) ?>">
<div class="trigger"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></div>
<div class="triggerContent" style="display: none;"><span><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></span></div>
</div>
<?php } ?>
</div>
<script type="text/javascript">decorateTable('product-attribute-specs-table')</script>
You need to copy the default file from /app/design/frontend/base/default/template/catalog/product/view to your theme directory
/public_html/app/design/frontend/default/yourtheme/template/catalog/product/view

Resources