I have a grid and associated store which is used to display data about two different entities i.e. System and Customer . If the grid is shown after clicking on the System link,
the url to use is /configuration/systemid/234 and if it is from customer link url should be /configuration/customerid/234. Note that the value 234 will also change. How can I achieve this in ExtJs4 MVC model.
is there a way to provide the url as below and replace the placeholders?
url : '/configuration/{context}/{contextid}'
Or can I store the context in an object and use it here , like
'/configuration/' + Context.type + '/' + Context.id
or is there a standard solution for this ?
The urls are given by backend dvlprs and can not be changed :(
i have the store defined as follows
Ext.define('MyApp.store.Configuration', {
extend: 'Ext.data.Store',
model: 'MyApp.model.Configuration',
autoLoad: true,
proxy: {
type: 'ajax',
url : '/configuration/customerid/234'
}
})
thanks
var yourStore = Ext.getStore('yourStoreID');
Context.type = customerid;
Context.id = 234;
yourStore.getProxy().setUrl('/configuration/' + Context.type + '/' + Context.id);
I have used something like this before, as my store had different urls for GET and POST. So dynamically you can easily change the URL.
Related
I would like to generate a Url in a list in keystoneJS. I prefer that the url not be stored in mongo.
Attempted:
Virtual field: works, but will not generate raw HTML for the href.
Types.Url: I get the href format, but I need a value from another field in my model, so it generates the url with undefined.. Example:
{ type: Types.Url, label: "Link", default: "[http://www.stackoverflow.com/ask?id=][1]" + this._id }
Any help on how to pull this off would be much appreciated.
For your second point, this._id is not available when adding fields to the model, hence why you're getting undefined.
Instead, try using a pre-save hook on your model:
yourModel.pre('save', function(next) {
this.link = "[http://www.stackoverflow.com/ask?id=][1]" + this._id;
next();
}
I'm not quite sure if you're trying to just generate a link in this way every time, or if the user should also be able to add their own link. If the later, you'll need to check if the link has been filled in in the pre-save hook.
I hope that helps and sorry it took so long to get an answer on this!
I am trying to get all pictures from a folder which is called 'Pictures',
but i am getting bad request error, here is my code:
const uri = "https://api.onedrive.com/v1.0/Drive/";
$("#btLeshoto").click(function () {
//set url for the leshoto folder
url += uri + "Pictures/children?$top=1000&access_token=" + token;
loadImages();
})
function loadImages() {
$.ajax({
url: url,
dataType: 'json',
// beforeSend: function(xhr){xhr.setRequestHeader('Authorization', token);}
}).then(function (data) {
}}
I have tried using apigee, but no succes. Maybe can someone help me with this ?
Thanks.
You'll want your URL to end up looking something like this:
https://api.onedrive.com/v1.0/drive/root:/Pictures:/children
The main differences with what you currently have:
You need to specify a starting item, and so in this case we put root after drive.
To use a path you need to "switch" to the path semantics (so the URL segments won't be treated as parts of the object model), and similarly switched back to access the object model again. This is accomplished with the :
Is there a way to the current request url or path in Handlebars? I need to be able to switch what parts of the theme is loaded based on paths. I've tried {{url}} ... no luck. Using latest Stencil with Cornerstone.
I had to do something like this for a project with 3 different category page layouts. Without custom category templates in Stencil, you have to get a little creative.
First, inject the handlebars URL into your category.js file using the BigCommerce's inject handlebar helper seen here. Then parse it so you get only the unique parts, then perform some logic based on what you want to do.
I used the breadcrumb li length as an indicator of how deep I was in the category tree. There is likely a better way, but this is what I thought of first, and it worked just fine.
category.html
{{inject "currentPage" category.url}}
category.js
var pageURL = this.context.currentPage;
var pageURL = pageURL.replace(/\//g," ").replace("http:","").replace("storeurl.mybigcommerce.com","").replace("storeurl.com","").trim();
var catName = pageURL.substr(0,pageURL.indexOf(' '));
console.log('pageURL = ' + pageURL);
console.log('catName = ' + catName);
console.log($('ul.breadcrumbs li').length);
if( $('ul.breadcrumbs li').length == 3 ){
if(catName == "black-decker"){
if($(".cat-img").length){
$(".page").addClass("model-list");
$(".cat-img").hide();
$(".page").append("<div class='model-wrap'><div class='model-catalog' data-reveal-id='myModal'><span class='click-larger'>Click to view larger</span></div></div>");
$(".sidebarBlock-heading").text("Select Your Model Number Below:");
$(".brand-img").each(function(){
$(this).addClass(catName);
});
} else {
$(".page").addClass("model-list");
$(".sidebarBlock-heading").text("Select Your Model Number Below:");
$(".brand-img").each(function(){
$(this).addClass(catName);
});
// make page full width
$(".page-sidebar.cf.Left").addClass("full-width");
}
}
// MORE CODE etc...
I made a module for Prestashop that will display content based on the given ID in parameter (&id=X).
I'd like to set a nice url for this module.
Using SEO and URLS, I see that it's possible, but it keeps the ?id=X in the url.
For example, if I define the url to my module to be
/pretty-module
I will have the same links but with the different id :
/pretty-module?id=1
/pretty-module?id=23
What I'd like to do, is the following :
/pretty-module => will set id to 1
/even-prettier-module => will set id to 23
I didn't saw a "parameters" options in the SEO & URLS page in the Backoffice, so I'm wondering if it's possible to do this.
you need to hook to moduleRoutes,
1) in your module install method:
if (!parent::install()
|| !$this->registerHook('moduleRoutes')
|| !$this->registerHook('displayFooter'))
return false;
2) creating corresponding hook
public function hookmoduleRoutes($params) {
$routes = array();
$routes['module-examplemodule-handler'] = array(
'controller'=>'handler',
'rule'=>'promo{/:code}',
'keywords'=>array(
'code'=>array(
'regexp'=>'[\w]+',
'param'=>'short_code'
)
),
'params'=>array(
'fc'=>'module',
'module'=>'examplemodule',
'controller'=>'handler'
)
);
return $routes;
}
module may have multi routes.
the convention is module-[MODULE_NAME]-[MODULE_CONTROLLER_NAME]
array explanation:
controller - handler (modules/examplemodule/controllers/front/handler.php)
rule - curly braces are params.. you can get an idea from http://example.com/admin/index.php?controller=AdminMeta
keywords - here you configure your params (curly braces) defined in the rule.
usage example: http://example.com/promo/ADSGD
in controller 'handler':
$short_code = Tools::getValue('short_code');
tested on prestashop 1.6
reference: https://books.google.co.il/books?id=BsSiBQAAQBAJ&pg=PT134&lpg=PT134&dq=prestashop+module+Routes+hook&source=bl&ots=JCb_4oz6el&sig=JwoQfIsOnJ49VJ752fEb01ivMZ8&hl=en&sa=X&ei=vH0QVePiDoXPaNSxgrAP&ved=0CEIQ6AEwBA#v=onepage&q=prestashop%20module%20Routes%20hook&f=false
Right now I'm running into a problem where I can't seem to change the param names page, start, limit, and dir for a Ext.data.Store.
In ExtJS 3 I could do this:
paramNames :
{
start : 'startIndex',
limit : 'pageSize',
sort : 'sortCol',
dir : 'sortDir'
}
I tried adding this configuration to the Ext.data.Store for ExtJS 4 however 'start', 'limit', 'sort', and 'dir' still show up as the default param names. I need to be able to change this as the server side functionality requires these param names. This also causes paging and remote sorting to not work since the param names don't match what the server side resource is expecting.
So is there a new way in ExtJS 4 to change these param names like in ExtJS 3?
take a look at Proxy,
see http://docs.sencha.com/ext-js/4-0/#/api/Ext.data.proxy.Server
directionParam,limitParam...
To dynamically modify the parameters just before the load of a store you can do this:
/* set an additional parameter before loading, not nice but effective */
var p = store.getProxy();
p.extraParams.searchSomething = search;
p.extraParams.somethingelse = 'This works too';
store.load({
scope : this,
callback: function() {
// do something useful here with the results
}
});
Use this code:
proxy: {
type: 'ajax',
url: '/myurl',
method: 'GET',
**extraParams: { myKeyword: 'abcd' },**
reader: {
type: 'json',
root: 'rows'
}
}
Now you can change your myKeyword value from abcd to xyz in following way.
gridDataStore.proxy.extraParams.keyword='xyz';
gridDataStore.load();
this will set your parameters' value and reload the store.
The keys were renamed and moved to the Ext.data.Proxy object. Here's a simple example that tells ExtJS to use the default Grails parameter names:
Ext.create('Ext.data.Store', {
// Other store properties removed for brevity
proxy: {
// Other proxy properties removed for brevity
startParam: "offset",
limitParam: "max",
sortParam: "sort",
directionParam: "order",
simpleSortMode: true
}
});
I also set the simpleSortMode so that each of the parameters are sent to the server as discrete request parameters.