Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9018975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:39:57+00:00 2026-06-16T04:39:57+00:00

I’m looking to properly factor my views, to not generate much duplication. I’m using

  • 0

I’m looking to properly factor my views, to not generate much duplication. I’m using the Play framework, and the elements I’d like to factor out are basic common ones – headers, footers, navigation elements.

What is the standard pattern for this type of factoring? When I read about the view inheritance features, they sound as if they don’t allow for reuse of components.

I’m working with version 2.0 of Play.


Say, for example, that I have a common layout for multiple pages, and I’m looking to have swappable bits – say, the central content bit, and the footer, where different pages I’m displaying have different combinations of footer and content.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:39:58+00:00Added an answer on June 16, 2026 at 4:39 am

    You should use combination of layouts and tags as described in the documentation.

    Layout wraps current view, so it’s best place for starting and ending the HTML structure, adding scripts into head section of the hTML doc, and placing typical elements – such as stable header with logo, footer with copyrights etc. If you have the same main navigation on all pages, you can put it in layout too, then you can add params to the layout view to make it possible easily changing CSS classes for the active item. Note, that if you have for an example 2 different versions of main nav (for an example, one for common users, second for administrators only), you can just create 2 different layouts or use one layout and display two different versions depending on some param passed from the initial view.

    Tags are used for injecting code into current view (so they has just opposite role than layouts). They are a common views without layout, and are functions with params too. They are used mainly for placing things that are changing on every page or even request – for an example notice boxes (from the doc: success, error, etc). Also they are useful for subnavigation, especially, when it’s changes on every ‘branch’ from main navigation and it’s possible, that on some pages it should not be displayed at all.

    You can also use tags in the layouts (and probably, vice versa) so as you can see, there are many possibilities 🙂

    Note: palako’s sample illustrates it quite well, but it’s typical for Play 1.x templating engine, for Play 2.x check referenced documentation and/or sample application delivered with the source of Play.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.