Google Maps API MissingKeyMapError via Magento Plugin - javascript

I've had a look through the forum already, but can't seem to find an answer for my specific problem.
So, I've installed a third party 'store locator' plugin on my Magento store but I keep getting a js error message about MissingKeyMapError. I've already applied for an API key - but my problem is I'm not sure where in the code I should put this key.
API Key
I'm in Googlemap.php in the app folder for this particular plugin and I think it should go in here somewhere but not entirely sure.
This is what's contained in Googlemap.php:
class Clarion_Storelocator_Block_Adminhtml_Storelocator_Edit_Tab_Googlemap extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$model = Mage::registry('storelocator_data');
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('form_General_Googlemap', array('legend'=>Mage::helper('clarion_storelocator')->__('Google Map')));
$radiusConfigValue = Mage::getStoreConfig('clarion_storelocator_general_setting/clarion_storelocator_display_setting/default_radius');
$fieldset->addField('radius', 'text', array(
'label' => Mage::helper('clarion_storelocator')->__('Radius'),
'note' => Mage::helper('clarion_storelocator')->__('Radius is in miles. If kept blank then default configured radius will be used (System > Configuration > Store Locator)'),
'name' => 'radius',
'value' => $radiusConfigValue,
));
$fieldset->addField('latitude', 'text', array(
'label' => Mage::helper('clarion_storelocator')->__('Latitude'),
'class' => 'validate-number',
'required' => true,
'name' => 'latitude',
));
$fieldset->addField('longitude', 'text', array(
'label' => Mage::helper('clarion_storelocator')->__('Longitude'),
'class' => 'validate-number',
'required' => true,
'name' => 'longitude',
));
$zoomLevelConfigValue = Mage::getStoreConfig('clarion_storelocator_general_setting/clarion_storelocator_display_setting/zoom_level');
$fieldset->addField('zoom_level', 'text', array(
'label' => Mage::helper('clarion_storelocator')->__('Zoom Level '),
'note' => Mage::helper('clarion_storelocator')->__('If kept blank then default configured zoom level will be used (System > Configuration > Store Locator)'),
'name' => 'zoom_level',
'value' => $zoomLevelConfigValue,
));
$data = $model->getData();
if(!empty($data)) {
$form->setValues($data);
}
return parent::_prepareForm();
}
}**
Any help/suggestions would be much appreciated!
Thanks in advance,
Letitia

I also had same issue with this extension just find the xml file under your theme layout mainly named with clarion_storelocator.xml in this find google api path under script tag in line no #32 replace with src="//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&key=YOUR_API_KEY" async="" defer="defer" type="text/javascript"> under script tag
Remember to put your api key.
Enjoy Coding :)

Related

Is there a way to have a wordpress post category that is functional but not visible?

I would like to display categories in posts and in post excepts, however I would alo like to use categories that help organise the display of posts around the site but are not visible.
For example a 'featured' category that may be applied to a range of posts in unconnected categories, but that are the most valuable posts to show in a particular area. I don't want the category 'featured' to show to the user.
you're looking at custom taxonomies. Custom taxonomies can be applied to multiple posts. You can control their behaviour by using arguments.
CTs looks somewhat like that and are declared in your function.php file
<?php
/**
* Add CT to CPT
*/
add_action( 'init', 'custom_taxonomy_langues' );
function custom_taxonomy_langues() {
$taxonomy = '_related_CPT_goes_here';
$singular = '_CT_singular_name';
$plural = '_CT_plural_name';
$labels = array(
'name' => $plural,
'singular_name' => $singular,
);
$args = array(
'labels' => $labels,
'description' => '',
'hierarchical' => 1,
'public' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => false,
'rewrite' => array( 'slug' => strtolower( $plural ), 'hierarchical' => 1 ),
);
register_taxonomy( strtolower( $plural ), strtolower( $taxonomy ), $args );
}; ?>
As you can see you can control pretty every regarding the behaviour, can you query them, do they have an archive page, do you want them to show up in the admin ui, if so where ... etc
A bunch of article already exist, you can take a look at this one https://wordpress.stackexchange.com/questions/92430/can-multiple-custom-post-types-share-a-custom-taxonomy in regards to connecting multiple CPTs to a single CT.
Use a custom taxonomy instead.One can specify that they are not public, but still use them for querying and grouping. https://developer.wordpress.org/reference/functions/register_taxonomy/

Jump to record editing in TYPO3 backend via JavaScript

I want to jump to a specific record in the TYPO3 backend via JavaScript.
I got a modal and a "jump" button that should take a PID and a record UID and jump to the records edit view. I know this works with PHP, but is there an API in the FormEngine or somewhere else in the TYPO3 backend JS Framework that can do this?
I discovered top.getModuleUrl and top.loadEditId but the first one will jump to a module - which I don't know if the edit view is - or jump to the edit view of a page, not a record.
So what I am trying to do in code would be the following:
var $modal = Modal.confirm( noteRecord.subject , noteRecord.message, Severity.info, [
{
text: TYPO3.lang['sys_note.dismiss'] || 'Dismiss',
active: true,
btnClass: 'btn-error',
name: 'dismiss'
},
{
text: TYPO3.lang['sys_note.showRecord'] || 'Go to record',
btnClass: 'btn-warning',
name: 'goto'
}
]);
$modal.on('button.clicked', function(e) {
if ( e.target.name === 'dismiss' ) {
Modal.dismiss();
} else if ( e.target.name === 'goto' ) {
Modal.dismiss();
/*
* At this point, the noteRecord contains a pid and a uid we want to
* call somehow
*/
// something like: TYPO3.callRecordEditModule(noteRecord.pid, noteRecord.uid);
}
});
In PHP I create the edit URL the following way:
<?php
$url = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(
'record_edit',
array(
'edit[' . $table . '][' . $uid . ']' => 'edit',
'returnUrl' => \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')
)
);

yii2 dynamic-form wbraganca call javascript function

I have read some articles about yii2 dynamic-form and javascript function. The solution given by InsaneSkull is perfect. But i have one question.
example :
i'm using dynamic-form from wbraganca and trying to call function onchange event (javascript). My code like this
<?= $form->field($detail, "[{$i}]qty")->widget(\yii\widgets\MaskedInput::className(),
[
'clientOptions' => [
'alias' => 'numeric',
'groupSeparator' => ',',
'digits' => 0,
'autoGroup' => true,
'removeMaskOnSubmit' => true,
'rightAlign' => false,
],
'options' => [
'class' => 'form-control',
'onchange' => 'Info($(this))',
]
]) ?>
First, i try to register Info function like below
<?php
$script = <<< JS
function Info(item){
var index = item.attr("id").replace(/[^0-9.]/g, "");
alert(index);
};
JS;
$this->registerJs($script);
?>
It gave error because Info function not defined yet.
Second, I registered in AppAsset and it worked.
My question : what is the differences? *(I think it was the scope).
How to define the function beside register in AppAsset ?
Where dou you register above script? If in view after use widget, default position at which JS is register is POS_READY public void registerJs ( $js, $position = self::POS_READY, $key = null ) Try to use position POS_BEGIN or POS_HEAD if you want to put the script after use widget. Otherwise You can override widget class and put this script into init method of the widget which is execute before run method rendered widget.

Yii2 - array with URL:s in listView

I have an array, Vehicles, "id" and "vehicle", like this database table:
Vehicles
1.Car
2.Truck
3.Bicycle
4.Motorcycle
I make a model of the table, and CRUD it, I am given this generated code in vehicle/index:
<?= ListView::widget([
'dataProvider' => $dataProvider,
'itemOptions' => ['class' => 'item'],
'itemView' => function ($model, $key, $index, $widget) {
return Html::a(Html::encode($model->vehicle), ['view', 'id' => $model->id]);
},
]) ?>
I see now a list with all my vehicles as links:
Car,
Truck,
Bicycle,
Motorcycle
What I want, is the links to get me somewhere, like this:
Car - vehicles/car,
Truck - vehicles/truck
...etc
I will have to hard-code the paths, I guess.
Is there a convenient way to do this, in the Html::a function given above?
Or should I use another type of function?
You can use the urlManager
return Html::a(Html::encode($model->vehicle),
['/your-controller/your-action', 'id' => $model->id]);
assuming your controller is name vehicle and in $model->name you have car, or Trukck ...
return Html::a(Html::encode($model->vehicle),
['/vehicle/'. $model->name, 'id' => $model->id]);

Dynamically assign variable to jquery autocomplete query string

I'm coding form where a user can submit playlists. There is an 'artist' field and a 'song' field. Both are input type 'text'.
I'm attempting to use jquery's autocomplete functionality in both fields. Autocomplete results for the artist are functions of user-keystrokes and autocomplete results for songs are functions of user-keystrokes AND the value of the artist input field.
Autocomplete seems to work to populate a list of suggestions under the artist input field. search.php is the script reading the query string.
$(".artist").autocomplete("searchDev.php?type=artist&"+mydate.getTime(), {
width: 180,
selectFirst: false
});
In search.php, a var_export of $_GET in searchDev.php after an a keystroke yields
array (
'type' => 'artist',
1367531572213 => '',
'q' => 'a',
'limit' => '10',
'timestamp' => '1367531576911',
)
This is just fine.
However, when I try to supply a variable to the query string(here window.sartist) in autocomplete(for the song input field),
$(".song").autocomplete("search.php?type=song&sartist="+window.sartist+"&"+mydate.getTime(), {
width: 180,
selectFirst: false
});
sartist is not defined correctly, ie var_export($_GET) in search.php yields
array (
'type' => 'song',
'sartist' => '[object HTMLInputElement]',
1367525807081 => '',
'q' => 'a',
'limit' => '10',
'timestamp' => '1367526169637',
)
if a global variable, not attached to the window is used in place of window.sartist in the query string, var_export($_GET) yields
array (
'type' => 'song',
'sartist' => '',
1367528252501 => '',
'q' => 'a',
'limit' => '10',
'timestamp' => '1367528260585',
)
So I suspect that the query string cannot be modified after it is loaded. Does anyone have a viable workaround to allow variables to be dynamically assigned to the autocomplete query string? Basically I need the 'song' autocomplete suggestions contingent upon the value of the 'artist' field.
You just need to use a function as source to pass multiple dynamics params to the query :
$('.song').autocomplete({
var value = $(this).val();
source:function( request, response ) {
$.getJSON( "searchDev.php", {
term: value ,
data:{
type:"song",
myparam:$('#myparam').val()
}
}, response );
}
})
In this example, if current input .song have value 'high hope' and the #myparam field have value "pink" the query will looks like : searchDev.php?term=high+hope&type=song&myparam=pink
Fiddle (no real data source, just see the console) : http://jsfiddle.net/RfuBP/3/
Doc for the source option of jquery autocomplete : http://api.jqueryui.com/autocomplete/#option-source
PS : In your code, are you sure that window.sartist returns a value and not the element ?

Categories

Resources