Created 6 years ago by pdring

Hi, I'd like to pass a parameter in the URL and then retrieve that parameter in the view. For example to edit a Stream entry, the URL could be where 1 is the ID of the entry. I'm just not sure about how to access my views. At the moment I'm using the starter template at core/pyrocms/starter-theme. In views/layouts I have a file called edit.twig. Based on the Laravel documentation, I would have guessed something like: Route::get('edit/{id}', function ($id) { return view('edit', $id); }); However it doesn't look like the view is recognised. The routes in routes/web.php are set up to look in resources/views, not the starter theme. Do you know how I would go about routing to my edit.twig file? I can then use exactly the same page and simply swap out the URL parameter to edit the correct entry. It would also be useful to know how to call the URL parameter on the page 😄 Thanks!

ryanthompson  —  6 years ago

Views will need to extend your default layout and define a content block. Then you can get the ID in your view if you want like request_segment(2) or request_get('id').

ryanthompson  —  6 years ago

An example of a simple view would be like this:

{% extends "theme::layouts/default" %}

{% block content %}
    Hello there! The ID is {{ request_get('id') }}!
{% endblock %}
pdring  —  6 years ago

Awesome thanks!