I’m brand new to EE2.9.2 and I would like to generate a dynamic list of vehicles entered into EE. I enter in the following channel “vehicles” and the following channel fields “year”, “make” (dropdown), “model” (textinput), “images” (upload), “content” (textarea). First I’m wondering how I should accept the “year” value? The calendar picker is not really what I am looking for—- rather, just 4 digits and numeric only.
Also, after I add a number of vehicles, how I can generate a dynamic list of all of the vehicles? So that it will show “year”, “make”, “model” (2012 Honda Civic) and a link to each vehicle page from this list?
I have a few other things I would like to do with the site, but this is a good start.
Thanks for the help! I was able to deconstruct this code pretty well. When I got it, it made sense. Segments make it so easy based on the URL structure!
So this will show up to 10 of the vehicles entered in with the vehicle_make channel field set to “Nissan”. This is so powerful! With that being said, if I don’t have any Nissan entries added, it will show all of my entries to all of the makes. Is there any way to disable that from happening? Perhaps have it say “No entries are found.” if that’s the case?
A few more side notes:
Can I rearrange the EE top navigation to have custom links all the way over on the left? Sort order wants to put all custom links to the right, adjacent to “Tools”.
And is it possible to disable the required *Title field from my channel? I have tried a couple of third_party downloads but to no avail:
SP Title Filler
MX Title Control
I understand that the title is required for editing the entry (having a link to click on). But can I generate this title based on some other channel fields included in the channel group, such as the following value “{vehicle_year} {vehicle_make} {vehicle_model}”?
Indeed, when you have that “lightbulb” moment you start to see how powerful it is and the endless possibilities you have with manipulating content. You’ve only just scratched the surface so keep on playing, with EE there’s no right and wrong ways of doing things but it’s worth setting up a dummy site so you can test if your methods work, and try different ways of displaying content, rather than commit to a dev build straight away.
To show a no results message just add the no_results tag inside the exp:channel:entries tag like this:
{exp:channel:entries channel="vehicles" limit="10" search:vehicle_make="{segment_3}"}
{vehicle_year} {vehicle_make} {vehicle_model}
{if no_results}
<p>Nothing found for that vehicle.</p>
{/if}
{/exp:channel:entries}
You always have to use the Entry Title. You don’t have to output it on the front end so I’d suggest come up with a formula for those entries, perhaps summarise the vehicle or other entry content eg “Nissan Micra 2001-2005” so you can quickly reference it if you want to make content updates.
You can’t do much with the main CP menu out of the box, I rarely add any custom links there, and even for clients perhaps one or two extra links to things like Modules they use a lot. If you did want to extend it use https://devot-ee.com/add-ons/zoo-flexible-admin - that will allow you to create custom menus per member (login) group.
So let’s say that I have a field channel group called “Manufacturer”, in here I have a picture of the emblem, history of the make, corporate info about the make.
Another field channel group called “Vehicle” where I enter in all of the info about the vehicle (year, make, model, images of the vehicle).
Would I want to use a Relationship to tie Vehicle to Manufacturer? So that when I go to the /browse/make/nissan/ URL it will show the emblem image of Nissan from the Manufacturer channel group, and the vehicle listings of Nissan from the Vehicle channel group?
I would rather have the site automate the emblem image for these details pages, rather than adding the very same emblem image to each and every vehicle entry.
Ok that makes sense, 2 channels manufacturers and vehicles(models).
As manufacturer data is pretty much fixed, in that you won’t change it very often the best way is to do the relationship from the vehicle channel.
So in your Vehicle channel create a “Relationships” field, assign the relationship to take data from the Manufacturers channel, and limit the number of relationships to 1 (you don’t nee more!).
Once the relationship is made you can then pull in the related data two ways.
On a vehicle page (entry) you show the related manufacturer using the bog standard relationship field tag:
{exp:channel:entries channel="vehicles" limit="10" search:vehicle_make="{segment_3}"}
<!-- pull in related data -->
{v_relationship_field}
{v_relationship_field:title}
<img src=""{v_relationship_field:logo_field}" alt="">
{/v_relationship_field}
{vehicle_year} {vehicle_make} {vehicle_model}
{if no_results}
<p>Nothing found for that vehicle.</p>
{/if}
{/exp:channel:entries}
On a Manufacturers page the relationship is a “parent” because the relations was made elsewhere. For that you’d use:
{exp:channel:entries channel="manufacturers" limit="10"}
<h1>{title}</h1>
<img src=""{man_logo_field}" alt="">
<!-- pull in parent related data, use field value from vehicles channel field -->
{parents field="v_relationship_field"}
{parents:title}
{parents:vehicle_year}
{parents:vehicle_make}
{parents:vehicle_model}
{/parents}
{if no_results}
<p>Nothing found for that manufacturer.</p>
{/if}
{/exp:channel:entries}
OK I may need to take a good hard look through this code a few more times to see if I can understand it all.
Update: OK, I’ve had a few more looks through it and I’m starting to understand more again. Those lightbulb moments are feeling great.
Is “v_relationship_field” a placeholder for what my field name is?
For my details page template do I want to create it in the “/browse” template group? I already have “type”, “make”, “country” and “index” in that template group, and it’s only because they belong as segment_2’s when they show up after “/browse/”.
I’m noticing that /browse/make/nissan/ is a segment_3, even though I don’t have a “Nissan” template created, EE creates the “Nissan” URL entirely on it’s own and pulls from the parent template if none is provided for it. This is perfect for the vehicle make pages utilizing segment_3 URLs (for now), but the details pages will need to be a different layout than my /browse/make/ pages.
My URL structure is going to be example.com/browse/make/nissan/1999-nissan-skyline-gtr/
Can I tell the details page template to only load up as a segment_4 view, and only after “/browse/make/{vehicle_make}/” to avoid any problems with other segment_4 pages?
Now, for your inner pages you could create templates like /type /make etc, or you could run everything from the index template using “conditionals” to pull in data according to how many segments you have, eg
{if segment_2 == ""}
Browse top level page /browse
{/if}
{if segment_2 == "make"}
{if segment_3 != "" AND segment_4 == ""}
List all types /browse/make/nissan
{/if}
{if segment_4 != ""}
List type detail browse/make/nissan/1999-nissan-skyline-gtr
{/if}
{/if}
There are pro’s and cons of this method, if you wanted your templates a lot cleaner and easier to read I’d go down the route of using separarete inner templates … next post!
/browse/make template assuming you relate each vehicle type to the make. Assuming the url is /browse/make/nissan
{exp:channel:entries channel="manufacturers" limit="1" url_title="{segment_3}"}
<h1>{title}</h1>
<!-- pull in parent related data, use field value from vehicles channel field -->
{parents field="type_relationship_field"}
{parents:title}
{parents:vehicle_year}
{parents:vehicle_make}
{parents:vehicle_model}
{/parents}
{/exp:channel:entries}
Thanks, Bluedreamer!
Conditionals look like a very powerful tool. I do like the idea of separating the templates to clean up the code a bit more, and in the ideal world I would have a “details” template in my /browse template group perhaps.
I am still a bit confused how I would load a separate design altogether for the details pages. I see in the conditionals post I can load the content for the details page into the index page template:
{if segment_4 != ""}
List type detail browse/make/nissan/1999-nissan-skyline-gtr
{/if}
However, will this not assume I’m running the very same index page template design? The index page template design is going to be a lot different, in terms of how it’s structured in markup. The same goes for the way it is structured compared to the /browse/make template design, as per the second post.
Hope I’m not missing something here?
Thanks again!
You can have whatever HTML/structure you want in any template, so your /browse/index and browse/make templates you can add whatever HTML you wish, plus the exp:channel:entries tag will also output whatever HTML you want. So with that combination you have endless possibilities.
Now, if you have just an index template (no /make template etc) when you call the URL /browse/make/nissan EE will always use the index template. However if you have a /browse/make template and you call /browse/make/nissan because segment 2 matches a template named /make EE will use that. Basically EE checks for the existence of a template, if it finds one it uses that, if not it falls back to the index template.
And so because of that you can style your /browse/index template (+ EE tags in the template) however you want, then in the /browse/make template (+ EE tags in that template) you can use totally different markup as you want.
Oh OK, so is there no way to create an entirely stand alone “segment_4” template in EE? Or will I need to share the same “segment_2” template and work from within that? With the URL structure being “/browse/make/nissan/1999-skyline-gtr/” for example, “nissan” (segment_3) and “1999-skyline-gtr” (segment_4) being entirely dynamic based on the channel fields. I am OK with segment_3 sharing the segment_2 design layout (for now) but for segment_4 I would like to use an entirely different layout. And not see segment_2 markup in that same template when I am editing segment_4 if possible.
Because I can put an entirely new template design up for the segment_1 and segment_2 very easily, based on the folder structure that /browse/index and /browse/make provide and being as they are always static. But I think a part of me is expecting a sub-folder for /browse_all/browse_makes/make/vehicle_details to put all of my segment_4 markup into for any pages that follow the first three segments “/browse/make/{make_title}/”. I don’t like sharing template files for altogether different layout designs because I feel that it can get messy and bloated very quickly lol.
Do you know if there are any plugins to allow stand alone “higher segment” template designs? Or perhaps this is just the way EE works (on purpose) and I still need to wrap my head around that some more to understand the real potential behind it…
Really liking EE so far! For someone who is very familiar with front end HTML and CSS markup and inexperienced with programming in PHP I am finding EE to be lightyears ahead of Drupal and WordPress for building more of the complex things.
With the custom template design part figured out for higher segment URLs I think I should be well underway to building an awesome website filled with content!