1

I'm pretty new to Craft and PHP, and I am needing to design a page in Craft (powered by a plugin) which will pass a variable in a querystring (or equivalent in Craft) to the PHP code in the plugin.
In my case, it would be a username (e.g. jsmith) to pass to the plugin PHP code, which would query an XML file for a node having 'jsmith' as the username value.
My first question is - in Craft, can I use a querystring like: ?username=jsmith

or would I need to use something more Craft-specific?

My second question is - can Craft (Twig template) pass to the PHP plugin by including the PHP file (service)?

Thanks for your help in this

1

If you have a URL like this:

mysite.com?username=jsmith

You can retrieve it from your plugin via craft()->request->getQuery('username');

See here: https://craftcms.com/classreference/services/HttpRequestService#getQuery-detail

My second question is - can Craft (Twig template) pass to the PHP plugin by including the PHP file (service)?

I'm not actually following this question, but we generally try to keep to one question per post. I'd suggest posting a new one for that with some additional details of exactly what you're trying to do.

Would also suggest giving the official plugin documentation a read-though: https://craftcms.com/docs/plugins/introduction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.