Joomla 3.5.1 - PHP Notice: Undefined index: doTask - joomla

I'm developing a backend component for Joomla and when I access certain views of my component the notice below gets logged. I'm currently running Joomla 3.5.1. Has anyone got the same notice?
PHP Notice: Undefined index: doTask in /var/www/html/layouts/joomla/toolbar/popup.php on line 14

The reason for the notice was that I created a popup button like this:
$layout->render(array('name' => 'print', 'text' => JText::_('BUTTON_PRINT'), 'class' => 'icon-print'));
Adding doTask parameter fixed the problem and the notice is not showing anymore.
$layout->render(array('name' => 'print', 'doTask' => '', 'text' => JText::_('BUTTON_PRINT'), 'class' => 'icon-print'));
I looked at the popup.php file and after that it was pretty easy to figure out the cause. As you can see $doTask variable is used every time when a popup button is rendered.
<button value="<?php echo $doTask; ?>" class="btn btn-small modal" data-toggle="modal" data-target="#modal-<?php echo $name; ?>">

Related

How oin blade form show old value?

In laravel 8/ bootstrap 4 / laravelcollective/html 6.2 app
I use old in form field definition :
{!! Form::text(
'name',
!empty(old('name'))? Purifier::clean(old('name')): $user->name,
['placeholder' => 'Name','class' => 'form-control editable_field', 'autocomplete'=>'of']
) !!}
#error('name')
<p class="validation_error" role="alert">{{ $message }}</p>
#enderror
as it works ok, expect cases when from database value was read but cleared by operator:
then old value is visible.
I tried this way
isset(old('name'))? Purifier::clean(old('name')): $user->name,
But got error:
Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
Can you advice proper way ?
Thanks!

how to apply select2 in Yii2 dropdown list

In yii2 basic ActiveForm i have added a drop-down list and in it used the "options" array to add my attributes .i want to add select2 in my drop-down but it is not working .i have searched on web and found this method of "options" array i have used below but still its showing no output in the view
<div class="col-xs-6 col-lg-6">
<div class="form-group form-material floating" data-plugin="formMaterial">
<div class="example"> <b role="presentation"></b>
<?= $form->field($model, 'corporation_status')->dropDownList(Yii::$app->appstatues->status,['options'=>['class'=>'form-control','prompt'=>'abc','data-plugin'=>'select2']])->label('Stat'); ?>
</div>
</div>
</div>
Any help would be much appreciated.
Use extension https://github.com/kartik-v/yii2-widget-select2
many good extensions is there too:
http://demos.krajee.com/
Found the solution for "select2" to be added to your drop-down list do the following steps:
Add following css and js files to your "AppAsset":
https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css
https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js
and in the form field add 'data-plugin'=>'select2' like this:
<?= $form->field($model, 'corporation_status')->dropDownList(Yii::$app->appstatues->status,['prompt' => 'hello','data-plugin'=>'select2','class'=>'form-control'])->label('Status'); ?>
Run this command to install kartik\select2 widget for yii2
php composer.phar require kartik-v/yii2-widget-select2 "#dev"
Then to use the widget.
//Include kartik\select2 Class
use kartik\select2\Select2;
// Normal select with ActiveForm & model
echo $form->field($model, 'corporation_status')->widget(Select2::classname(), [
'data' => Yii::$app->appstatues->status,
'options' => ['prompt' => 'Select a state ...'],
'pluginOptions' => [
'allowClear' => true
],
]);

Laravel form binding

Hi I am using laravel form binding along with
jqBootstrapValidation . In order to successfuly have the validate the input fields, I must pass something like "required" (without quotes) in the tag . Can you please let me know how can I achieve this ?
FYI .. the minlength works fine but the required does not work.
For example one of input elements currently looks as such
{{Form::text('username', null, array('class'=> 'form-control tip', 'data-toggle'=> 'tooltip', 'data-placement'=> 'bottom', 'title'=>'Enter your username that you have been using till now. This is a compulsory field.','placeholder'=>'Username ( must be filled )','minlength'=>'2'))}}
Thanks
You can't, take a look at the source code that builds the attributes:
protected function attributeElement($key, $value)
{
if (is_numeric($key)) $key = $value;
if ( ! is_null($value)) return $key.'="'.e($value).'"';
}
You'll always get a <attribute>=<name>, what you can test is to use it this way:
{{ Form::text('username',
null,
array( 'class'=> 'form-control tip',
'data-toggle'=> 'tooltip',
'data-placement'=> 'bottom',
'title'=>'Enter your username that you have been using till now. This is a compulsory field.',
'placeholder'=>'Username ( must be filled )',
'minlength'=>'2',
0 => 'required'
)
)
}}
It will build a tag
<... required="required" ...>
And it might work for jqBootstrapValidation.
Otherwise you'll have to create those inputs manually.
I've used this with the HTML attributes required="required" and also required="" works too. Changing the example they provide and adding in the Laravel Blade tags gives
<form class="form-horizontal" novalidate>
<div class="control-group">
<label class="control-label">Type something</label>
<div class="controls">
{{ Form::text('name', null , array('required' => '')) }}
<p class="help-block"></p>
</div>
</div>
{{ Form::submit('submit')}}
</form>
This worked fine and produced the error "This is required". I swapped in your form field and added in the
'required' => ''
to the end of your attribute array and that too worked just fine. Alternatively you could instead add in
'required' => 'required'
as jqBootstrapValidation picks up either. Good luck.

Magento Custom Image Attribute from Related Products

So from the product view i am getting related products to display. For reasons i wont get into i need to display the image of the related product but it has to be a custom image attribute. So i have created a custom image attribute called colour_swatch and i need to access it and display it on screen. I have done some reading on the issue and have not managed to find a solution to fit my needs.
So here is my code:
<?php foreach($this->getItems() as $_item): ?>
<div class="eachProductRelated">
<a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>" class="product-image">
<img src="<?php echo $this->helper('catalog/image')->init($_item, 'colour_swatch') ?>"
width="20px" alt="<?php echo $this->htmlEscape($_item->getName()) ?>"/>
</a>
</div>
<?php endforeach ?>
If we replace colour_swatch with small image that of course will work. I have read that you can't access a custom image attribute if you aren't calling it directly from the product view. And a lot of the solutions i have seen seem to be massively overkill, Surely there is a simpler solution???
Might be worth telling you that i get the following error message:
a:5:{i:0;s:25:"Image file was not found.";i:1;s:4015:"#0
/Users/Frank/Sites/bosideng/app/code/core/Mage/Catalog/Helper/Image.php(163):
Mage_Catalog_Model_Product_Image->setBaseFile(NULL)
Is it possible that i have to do some kind of if no_selected check ?
I have figured out this issue and pardon my French but it was a ridiculous and a stupid oversight by Magento.
When setting up your new custom image attribute you must set 'Use In Product Listing' to yes in the drop down before you select the attribute type 'Media Image' because guess what!? When you select Media Image, Magento hides that option.
Credit to this guy whose post i found after ages of searching: http://thedistance.co.uk/journal/2011-10/missing-magento-media-images
Hello i think you add new image url in custom image attribute then call may be help you
<img src="<?php echo Mage::getModel('catalog/product')->load($product)->getData('colour_swatch'); ?>"
For those of you creating custom image type using installer, add the following to make image visible on both listing and view pages:
$this->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'colour_swatch', array(
'group' => 'Images',
'type' => 'varchar',
'frontend' => 'catalog/product_attribute_frontend_image',
'label' => 'Color Swatch',
'input' => 'media_image',
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
'visible' => true,
'required' => false,
'default' => '',
'used_in_product_listing' => true,
));
If Flat Catalog Category and Use Flat Catalog Product is set to Yes, then you can add the specific attributes to the collection
Like
$collection = Mage::getResourceModel('catalog/product_collection');
$collection->addAttributeToSelect('*');
$collection->addAttributeToSelect('attributes_name');
This is working perfect for me

CodeIgniter img tag

I'm using following code to display an image with CodeIgniter framework.
<?php echo img('sample/logo.png'); ?>
And this is producing following output::
<img alt="" src="http://localhost:8080/test/css/sample/logo.png">
Why it does not closes the tag with />
Also, how can i specify the alt text when i echo image?
thanks
According to user guide, it should end with />. I tried it out, and it works.
If you want a shorter tag, use this:
<?php echo img(array('src'=>'image/picture.jpg', 'alt'=> 'alt information')); ?>
Sometimes if you view source using certain browsers (firefox, chrome), it omits the /> tag. Try view source using a notepad or something, it should display proper /> tag.
$image_properties = array(
'src' => 'sample/logo.png',
'alt' => 'Me, demonstrating how to eat 4 slices of pizza at one time',
'class' => 'post_images',
'width' => '200',
'height' => '200',
'title' => 'That was quite a night',
'rel' => 'lightbox',
);
img($image_properties);
// <img src="http://site.com/index.php/sample/logo.png" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" />
reference : http://codeigniter.com/user_guide/helpers/html_helper.html#img
Dont echo an image like that, do it like this:
echo "<img src='sample/logo.png' alt='my company name' title='my company logo' border='0' />";
Remeber the location you have there is relative, you should try to stick to absolute paths were possible eg: "/test/css/sample/logo.png" to avoid confusion.
(sorry, missed the bit where you said you were using a framework).

Resources