Closed pierzo closed 5 years ago
I answered you on Youtube.
But I'm not sure what you mean by: "where('slug', '=', $this->param('slug')); })->get(); } ?> All tags are closed."
What does that mean. Did you write your code in PHP block?
Also let's continue this discussion here instead of YouTube because we can share code more easily here.
Ok, link to screen exerpt
Show me your code for that page. Seems to me that you didn't put it in PHP block.
`
<?php
function onStart(){ $this['movies'] = Kominki\Realizacje\Models\Realizacje::whereHas('typy', function ($query) { $query->where('slug', '=', $this->param('slug')); })->get();
}
?>
{% for realizacja in realizacje %}
<h2>{{ realizacja.nazwa_realizacji }}</h2>
...
{% endfor %}
Look, I told you several times to put your code in PHP block. Did you do that? Because I can't figure that out from your code. Did you watch the video about PHP blocks that I linked for you on YouTube?
Anyway your file should look something like this.:
title = "Single video"
url = "/:category/:slug"
layout = "default"
is_hidden = 0
==
// THIS IS PHP BLOCK. notice "==" symbols at the beginning and the end.
<?php
function onStart()
{
$this['movies'] = Kominki\Realizacje\Models\Realizacje::whereHas('typy', function ($query) {
$query->where('slug', '=', $this->param('slug'));
})->get();
}
?>
// END OF PHP BLOCK
==
// Your HTML + Twig code goes here.
Hope this helps.
I apologize for my ignorance of the subject. Now I know what's going on with this php block.
What I want to achieve above all is the categories. Let's say I want to do a car dealer website.
I create a cars database where there are columns: id, slug, car_name, description.
I create a second database of a car type with columns: id, slug, car_type (eg van, pickup, sedan)
And now I would like to have three sides
mysite.com/cars/ here all car categories are shown as links. When I click on a link, for example a van, I go to the page:
mysite.com/cars/van/ All van cars are displayed here as links. And when I click on one of them, I go to the page:
mysite.com/cars/van/:slug selected van car
I understand that I need to create a pivot database cars_types with columns car_id and type_id.
Or maybe... In the first database, add the column "category_id" and display on the page the list similar to:
record.category_id
Maybe it will be easier for us to get along :)
Categories should be easier to achieve than tagging or filtering. But I can not do it or it is not in the documentation. I would ask on the forum but it is read-only.
Take a look at this video, it deals with something similar to what you are asking. https://www.youtube.com/watch?v=sZXdruO2ac8
Hi, I've already asked you for a solution under a video on youtube. Your respond was:
You would create a page that would have this type of URL: "movies/genres/:slug" Now in PHP block of that file you would have something like this:
<?php function onStart(){ $this['movies'] = WatchLearn\Videos\Models\Video::whereHas('genres', function ($query) { $query->where('slug', '=', $this->param('slug')); })->get();
?>
So when you go to for example: www.yoursite.com/movies/genres/action you would get only movies that have a genre of action. Of course below PHP block you would have a some sort of loop to display those movies, something like this:
{% for movie in movies %}
{{ movie.title }}
{% endfor %}
So I did that and what I get on movies/genres/:slug site is:
where('slug', '=', $this->param('slug')); })->get(); } ?>
All tags are closed.
What I would like to achieve is the category page for movies.
Thank you, great tutorials!