Skip to content

Adding request.get/post to TimberSite#853

Merged
jarednova merged 4 commits intotimber:masterfrom
connorjburton:site-request
Feb 17, 2016
Merged

Adding request.get/post to TimberSite#853
jarednova merged 4 commits intotimber:masterfrom
connorjburton:site-request

Conversation

@connorjburton
Copy link
Copy Markdown

Issue

There is no easy way to access GET/POST variables in the Twig templates

Solution

Add site.request array that contains site.request.get and site.request.post

Eg.

/vacancies/?salary=30000

Requested salary: £{{site.request.get.salary}}
Requested Salary: £30000

@jarednova
Copy link
Copy Markdown
Member

Thanks @connorjburton! I love this. My only question is whether it makes intuitive sense to make this property a child of Site. Does this merit being its own object? IE:

Requested salary: ${{request.get.salary}}

(also correcting that strange dollar symbol you used in yr example) :-)

@connorjburton
Copy link
Copy Markdown
Author

Yeah request.get.salary is much better, was my first thought.

What is this $ you speak of!

@connorjburton
Copy link
Copy Markdown
Author

Re-factored to it's own class, will test fully tomorrow.

@jarednova
Copy link
Copy Markdown
Member

Awesome, thanks @connorjburton! The "$" are legal tender we use with dead kings on 'em

@connorjburton
Copy link
Copy Markdown
Author

I've just added the required interface functions, other than that it works. One thing I noticed, the composer autoloader needs to be updated with the new class. How is that handled on Plugin update? As of now, if I just drop these files in it throws a fatal error.

@jarednova jarednova merged commit d54a6b7 into timber:master Feb 17, 2016
@jarednova
Copy link
Copy Markdown
Member

@connorjburton — I was able to get everything working. Are you talking about when deploying the plugin to wp.org?

@connorjburton
Copy link
Copy Markdown
Author

Oh I guess its just pre-generated before deploying to wp.org

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants