0

I am new to drupal 8 however, I have experience in MVC pattern and used Django earlier. I want to create a page that points to localhost/home where I would like to show a slideshow from view slideshow module as well as some static contents like images, links, etc. If I were on django, I would simple redirect the parameters to display directly on template i.e something like HttpResponse(template.render(context, request)).

How do I do such thing is drupal 8? I have looked at lots of places and still cannot find anything. The solution that I have found till now is to create separate module for each page i.e home, about-us, etc. and route a Controller function. Is this the only approach? Please help. Thanks.

0

Pages in Drupal are largely composed of content types with fields attached to them, and sometimes, blocks (which can be created from Views).

You do not need to create custom routes and controllers for them, the core Node module takes care of this for you.

The core Path module will allow for custom aliases, and Pathauto will let you create automatic aliasing rules.

It would be a fairly rare thing to need to implement a route and controller just to display basic content in Drupal. 99% of the time it can be achieved with content types, Views, or panels.

You will probably want to review some of the material on Drupalize.me to learn Drupal content management.

  • Thanks for the answer. How would I show my static files, images and style some components on a page created using Structure>Pages? – Pant Sep 26 '16 at 20:32
  • You need to add the appropriate fields to the content type, or configure the WYSIWYG with a file/image embedder or Entity Embed. – Kevin Sep 26 '16 at 20:37
  • This is not what I require. I want to show some custom images on homepage and would also show slideshow created using view_slideshow. Something like a load a fix template with images and render the slideshow. – Pant Sep 26 '16 at 20:39
  • What does views_slideshow have to do with static images? – Kevin Sep 26 '16 at 20:41
  • I want my homepage with a container to show slideshow (updated using view_slideshow) as well as some other static images, links and texts. I have tried using Panels and bootstrap to write some texts and show images but the website does not look good enough. Also hovering and using animation is not possible. What I want is now to serve some static contents, apply animations as well as put a container to hold the views_slideshow. How do I do this? – Pant Sep 26 '16 at 20:46
0

For a front page you could use a template suggestion, or blocks and visibility settings.

You can place static content in the layout using a custom block with a text field, or add more fields for specific things like links (if you want them in seperate fields etc).

E.g. lets say you create a page--front.html.twig template suggestion in your theme, then add a region for a Views Slideshow block. Static content could be hard coded into this page--front template, or perhaps using custom blocks, nodes or whatever suits your purpose. For example if that content is in nodes you could create a View and display that in another region.

Alternatively you might create a module has blocks that hold the static content and place them programmatically or via the UI. Is this what you are really driving at?

Hovers, animations etc is a style/behaviour level thing that does not seem relevant to the original question.

  • Thank you for the response. I am having confusion on creating basic pages like about-us, faq, etc. I can create them using Structure>Pages, however it won't be attractive as I have to do add blocks to the layout. What I want now is to load my own template when /about-us is entered, which might contain some static texts, images as well as container to display another blocks. Thanks. – Pant Sep 27 '16 at 0:57
  • Then it's routing: drupal.org/developing/api/8/routing – Jeff Burnz Sep 27 '16 at 3:29
  • That's what content management is all about - if you want to build every content page manually through routes and controllers, why even use Drupal? It is counter productive. There are plenty of fields in D8 (Block Reference, Views Reference) and plenty of modules (Paragraphs, Panels etc) to achieve this, the only part you need is learn the theming system to get the desired, reusable, markup. – Kevin Sep 27 '16 at 16:01
  • Yes, agree with Kevin, I almost asked the "why even use Drupal" question myself, adding pages with routes is appropriate for forms, admin pages etc, but for content I think you're forgetting Drupal is, primarily, a content management system. – Jeff Burnz Sep 27 '16 at 21:04

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.