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

  • Home
  • SEARCH
  • 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 7063779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:45:15+00:00 2026-05-28T04:45:15+00:00

so basically my application looks like this <!DOCTYPE html> <html> <head> … </head> <body>

  • 0

so basically my application looks like this

<!DOCTYPE html>
<html>
<head>
    ...
</head>
<body>
<div id="content">
    <div id="content_left">
        // Some Stuff
    </div>

    <div id="content_right">
        <%= yield %>
    </div>
</div>
</body>
</html>

now i want to switch between a two column layout and a single column layout based on the controller (at best: also based on the method i’m using).

between the body and the content and also in there head there is way too much stuff for simply creating a second layout and adding this as a layoutcall in my controller without too much code duplication.

what i would love to do is something like this:

all should use this

<!DOCTYPE html>
<html>
<head>
    ...
</head>
<body>
 // much stuff
 <%= yield %>
</body>
</html>

and now i can switch between two layouts, f.e

single_col

<div id="content">
    <%= yield %>
</div>

or two_column

<div id="content">
    <div id="content_left">
        // Some Stuff
    </div>

    <div id="content_right">
        <%= yield %>
    </div>
</div>

and then in the last yield there should be the view that is related to my controller and method.

is there an easy way to achieve this?

thanks for all hints.

PLEASE leave a comment if something is unclear.

  • 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-05-28T04:45:15+00:00Added an answer on May 28, 2026 at 4:45 am

    Put the different parts of the layouts in partials! Then you render the partials based on what is in
    params[:controller] and params[:action]. For example:

    <% if params[:controller] == "controller_name" %>
         <%= render 'partial_name1' %>
    <% else %>
         <%= render 'partial_name2' %>
    <% end %>
    

    The params[:controller] and params[:action] are always available! This is an example to show you how it works. Of cause there shjouldnt be any logic in the view aswell!

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

Sidebar

Related Questions

My data looks like this: 00000000001 : `12341234...12341234' Basically a unique id value associated
I have an installation of CodeIgniter. Basically, my directory structure looks like this: |
I'm writing an application that is basically just a preferences dialog, much like the
Basically it breaks down like this: A master template page is loaded when one
I have a (rather dirty) datasource (excel) that looks like this: ID | Name
I have a struct that's used in my internet application, which looks like: struct
I need to write cross platform application (basically CRUD). Is usage of Java Swing
I have an iPhone application which basically is getting information from an API (in
When I say installed application, I basically mean any application visible in [Control Panel]->[Add/Remove
I am trying to design a new application which basically aims at providing biometric

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.