Component to setup plug in params - joomla

I would like to know if it's possible to pass params to some plugins using a component.
My 'Application' contains 2 plugins (system and content) and there are a few params which are the same in the 2 plug-ins (eg : Facebook API key).
So I was thiking about making a component to configure the plugin params, so there is only one configuration for the user.
Is is possible to do that ?

See JComponentHelper::getParams.
In your plugins you could use:
$params = JComponentHelper::getParams('com_yourcomponent');

Related

Where do I get the value for `shopOrigin` when using Shopify app bridge?

Throughout the documentation for the new App Bridge, Shopify refers to the shopOrigin value and how it's used to configure the Provider from app-bridge-react but they never specify how to get this value?
The react app is loaded inside of an iframe and the src includes the shopOrigin value as a query string param called shop, but when I try the following code I get the error window is not defined:
const params = queryString.parse(window.location.search);
const config = {
apiKey: process.env.SHOPIFY_API_KEY,
shopOrigin: params.shop,
};
1) Why would I be getting window is not defined in javascript code running in a browser?! This makes no sense to me
2) If this value can be read from of the provided libraries such as #shopufy/app-bridge-react please tell me how
Unless you're using a library tailored specifically to Shopify, you have to manually save the shop origin during OAuth authorization.
Hopefully this Shopify tutorial is of some assistance
The shopOrigin is available within your browser cookies.
If you followed the Shopify development for react and Node.js, you should already saved this after the Shopify authentification.
I am not sure what exactly is the need for shopOrigin, if you just wanted to go to admin section of the shop from client side you can use Redirect in app bridge. otherwise you can store the shop detail on server during auth process and create a get api to retrive the details on client side as needed.

Alipay post URL when click on order submit

Which parameters are needed to build a Alipay post URL ?
Currently using https://openapi.alipaydev.com/gateway.do? as a test URL and service is service=create_forex_trade
I think you need to add following parameters
openapi is used for testing purpose while mapi.alipay.net is used for actual transaction purpose
https://openapi.alipaydev.com/gateway.do?_input_charset=utf-8
body={ordernumber}
currency={AUD}
notify_url={notify_url}
out_trade_no={}
partner={partner_id}
price=1395
quantity=1
return_url={return_url}
service=trade_create_by_buyer
sign={encryption_sign_key}
sign_type=MD5

Web API get route values

Is there any way to statically get route values from a service method (outside of a controller) that is running in a Web API context? For example, I can do the following in ASP.NET MVC:
var mvcHandler = HttpContext.Current.Handler as MvcHandler;
var routeValues = mvcHandler.RequestContext.RouteData.Values;
I'd like to find the equivalent version of this code for Web API.
When I try to debug a sample Web API request and look at HttpContext.Current.Handler it is of type HttpControllerHandler, but this type doesn't have any properties to access route data.
EDIT
To try to help provide some more information. The code I am trying to read the value from is inside of a factory class I have that builds a custom object for my application.
You can use GetRouteData() extension on HttpRequestMessage. You would need to include System.Net.Http namespace to get this.
System.Web.Http.Routing.IHttpRouteData routeData = Request.GetRouteData();
I was able to find a solution that would get the route values for either an MVC request or a Web API request.
HttpContext.Current.Request.RequestContext.RouteData

Change group of a newly created User in PyroCMS

Using PyroCMS 2.2, how can I have a registration form assign a user to one of the new Groups I created. Within the admin panel, I have a created a user group called client. When my registration form within my module is sent, it creates the client, but sets the type for group to $config['default_group'] = 'user'; within the core module.
Is there a way for me to set the group to client for this specific registration form in this module?
I suggest this:
When you redirect the user to the costum registration form, set a session variable with value of your costume module name for example
Use PyroCMS events (Events::trigger('post_user_register', $id)) and build a events.php file for your module so that, after every user registration this event will be triggered and since you have set the session variable, you can decide to change the user group of newly created user to an appropriate one and be sure to unset the session variable after you are done.
Hope you get the idea.
It doesn't look like there is an inbuilt way to do this.
system/cms/modules/users/controllers/users.php:384
// We are registering with a null group_id so we just
// use the default user ID in the settings.
$id = $this->ion_auth->register($username, $password, $email, null, $profile_data);
It also appears it isn't possible to override the core modules.
Seems like you have 2 options:
Modify the core module
Try to port the user module into your own module

URL localization in Lenya

I am trying to localize Lenya publication URLs.
I store URL translation in the Document metadata and rewrite urls with URLRewriter transformator.
e.g. I build
/lenya/default/authoring/en/home
from
/lenya/default/authoring/index.html
But I can't find a simple way to force Lenya to tranlate incoming request URI back to the original path: /lenya/default/authoring/index.html
Really I want to process the request via pipelines using the original URL, not translated.
Is it possible at all? I had tried to add a servlet filter and use dispatcher, but filter can't access documents metadata because Environment object isn't in the processing stack yet at this stage...
(At this moment I see only one way - to update CocoonServlet and Cocoon classes)
Thanks!
I was able to do this via a RequestListener.
In the public void onRequestStart(Environment environment) method I create RequestWrapper with a new real URL and put it into objectModel. Also I change Environment context with a real URL: env.setContext("", realUrl, env.getContext())
This works fine!

Resources