Magento: how to remove paragraphs around Widgets - magento

I'm new to magento and I just put a widget in a cms page. After having a look at the source code I saw a surrounding p-tag around the widget. Is there a way to remove it without disabling the wysiwyg editor?

Turn on template hints in admin.
Assuming this is the template that the widget renders:
app\design\frontend\base\default\template\cms\widget\static_block\default.phtml
Copy this template to:
app\design\frontend\base\default\template\cms\widget\static_block\default.phtml
Replace the code from:
<div class="widget widget-static-block"><?php echo $this->getText(); ?></div>
to:
<div class="widget widget-static-block"><?php echo strip_tags( $this->getText() ); ?></div>
You can customize allowed html tags by including a second parameter:
https://php.net/strip_tags

Related

remove date from the reviews (comments) section in magento

I want to know how I can remove date from the reviews (comments) section in magento. I have tried removing the date code many time from the back-end, but still it is showing the date.
The elements you want to hide are of class .review-meta
If you're happy just to hide them rather than remove the code completely, simply add the following style to your css:
.review-meta{
display:none;
}
Alternatively, if you wish to completely remove the relevant code then copy the folder from app/design/frontend/base/default/template/review into your custom layout directory (eg. app/design/frontend/rwd/my_custom_layout/template), and then within the copy edit the file review/product/list.phtml as follows:
Remove the following code:
<span class="review-meta">
<?php echo $this->__('Review by %s', $this->escapeHtml($_review->getNickname())) ?>
/
<?php echo $this->__('(Posted on %s)',$this->formatDate($_review->getCreatedAt()), 'long') ?>
</span>

Magento product overview and detail separated view

I want to handle the product overivew separataly to the product detail view. I want to add additional text right behind the price in the product deatil view.
I tried to edit the view.phtml in path app/design/frontend/mytheme/default/template/catalog/product/view.phtml, refreshed caches and so on, but nothing changed.
In catalog.xml view.phtml will be load. So its seems correct.
But even when I try to echo "test" it doesnt show anything.
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<div class="std"><h2><?php echo $this->__('Details:') ?></h2>
</div>
</div>
<?php echo "test";
endif;?>
Do you have any hint?
Regards
Matt
You should enable template path hints in the backend to check which template file is used to render product page. Make sure that the cache is also disabled.

Using Laravel Blades

i have started working in Laravel, and working with .blade.php templates, but am not able to understand the benefit for using blad.php and also while having a master page, why we put our code in some other pages with #sections and #yeild
like
masterpage.blade.php
<div>
#yeild(section)
</div>
index.balde.php
#section
Hellow world
#endsection
why i need to do it like that? why we can't just put our Text in the same page instead of doing this method, what are the benefits if we code like that.
There are lot of benefits in using Blade with Laravel, please read it here
http://culttt.com/2013/09/02/using-blade-laravel-4/
The short answer for you questions is we do not need Blade engine in any project. However, using it brings many benefits.
Simplify script file
Like other templating engine, Blade engine simplify your PHP scripts by some replacement such as :
<?php echo $foo ?> changed to {{ $foo }} (reduce 8 characters)
<?php if ($condition): ?> changed to #if ($condition) (reduce 6 characters)
<?php echo trans('lang.key') ?> changed to #lang('lang.key') (reduce 11 characters)
...
Try to calculate how many character you can save if using Blade engine in your script.
Another thing I love in Blade engine is that we can create our own custom control structure. If you are tired of typing $var->format('Y-m-d H:i:s') every time you need to output a DateTime object. You can create custom matcher with Blade
Blade::extend(function($view, $compiler)
{
$pattern = $compiler->createMatcher('datetime');
return preg_replace($pattern, '$1<?php echo $2->format('m/d/Y H:i'); ?>', $view);
});
Now, all you need to to is replace $var->format('Y-m-d H:i:s') by #datetime($var).
View inheritant
By supporting section, Blade engine help developer organize their view file in a hierarchical and logical way. Imagine that you have HTML code for some pages of your website: a home page, a category archive page and a single post page. All there page have the same header, footer and sidebar. If we " put our Text in the same page instead of doing this method", the content of there files have a large amount of similarities, which cause any changes in the future very painful.
With Blade sections, create a simple master layout file like that
<html>
<body>
#section('sidebar')
<!-- this is header code -->
#show
#section('sidebar')
<!-- this is sidebar code -->
#show
<div class="container">
#yield('content')
</div>
#section('footer')
<!-- this is footer code -->
#show
</body>
</html>
In the view file for each page, you only need to take care of the main content of the page, instead of other parts.

Show intro-image and extra fields in Smart Search results in Joomla

I´m using Joomla Smart Search in my website and I´m want to show intro-image and some extrafields from the article in the search results.
Joomla Smart Search removes any html tags and I want to prevent to do this extra fields
in www\plugins\finder\content open content.php
then search for getListQuery , at the end of ->select list add ->select('a.images AS image'); save & close the file
in www\components\com_finder\views\search\tmpl open default_result.php
then search for class="result-title after the tag add these lines:
<?php $image=json_decode($this->result->image); ?>
<?php $aimage=$image->image_intro; ?>
<div class="search-img">
<a href="<?php echo JRoute::_($route); ?>">
<img src="/<?php echo $aimage; ?>" >
</a>
</div>
save & close
dont forget to purge & reindex the smart search
Smart search plugins say which fields should be indexed. You could replace some of the smart search plugins with ones of your own.
I have found a solution, not absolutly like I wanted but it works. The solution shows the intro-text and all inside the "read more" of the article in the search results (images, links and everything you want).
This solution was found here http://forum.joomla.org/viewtopic.php?p=2324152 and says something like this:
"You'll need to create a layout override for the components/com_finder/views/search /tmpl/default_result.php layout file using the steps described at http://docs.joomla.org/Understanding_Output_Overrides Once you've created the layout override, you should change"
<?php echo JHtml::_('string.truncate', $this->result->description, $this->params->get('description_length', 255)); ?>
in the layout file to:
<?php echo $this->result->summary; ?>
The location should be templates/template_name/html/com_finder/search/default_result.php
actually there is a very easy solution.
K2 saves the images based on the md5 hash of the id.
adding this:
<div class="search-img">
<img src="<?php echo JURI::base().'media/k2/items/cache/'.md5("Image".$this->result->id).'_M.jpg'; ?>" />
</div>
to the html override of the default_result.php will display the according k2 items (here in medium resolution)

Where can we modify the default links of the footer in Magento?

I want to get rid of the links in the footer of my website, someone started the dev of that website and left, now I can't modify it, because when I'm in the footer.phtml i can see that code :
<!-- Footer -->
<div id="footer">
<ul>
<li><?php echo $this->getCopyright(); ?></li>
</ul>
<?php echo Mage::getModel('core/variable')->loadByCode('footer_navigation')->getValue('html'); ?>
<div class="cl"> </div>
</div>
<!-- /Footer -->
I can't find the place where that class is looking for the links Mage::getModel('core/variable')->loadByCode('footer_navigation')->getValue('html')
I've been looking in catalog.xml where I found <reference name="footer_links"> but if I delet the code inside, nothing happen, it doesn't seem to be linked in any way with that.
I got the same problem in my menu where I see that class I don't understand : $categories = $this->renderCategoriesMenuHtmlCustom2(0, 'level-top'); Where does that refer too ?
Thanks :)
Login to your admin panel and go to System->Custom Variables. You should find the footer links there. You can remove the links through here (by deleting the HTML and plain-text fields), or by taking out the piece of code that loads the footer links variable (the line that calls loadByCode('footer_navigation')).
You can also delete the variable through the admin panel, but if you do this, you should also remove the code that calls it; it won't crash, but it can lead to confusion down the road.

Resources