September 15, 2013

How to have a centered bootstrap layout

User2594008’s Question:

I need to create a responsive layout, and I have used bootstrap before but I have never actually attempted this. Making full width designs is plenty easy, but I want a two column layout that would say.. have a max width of 900px together.

The example of what I am trying to do can actually be seen right here on stackoverflow. There are two columns to this site, but both columns are centered on the page right now with space to the left and right. I just need that (and responsive as well for smaller screens).

Assuming your container has an id of container you can center it by giving auto left and right margin like:

#container { 
   margin: 0 auto;
}

The width of a default bootstrap grid is 960px and is already centered by default. You only have to assign a class called container like

<div class="container">
     <!-- The begin your row -->
     <div class="row">
          <div class="span8">
               Demo right part of stackoverflow
          </div>
          <div class="span4">
               Demo left part of stackoverflow         
          </div>
     </div>
</div>
March 10, 2012

Send params in URL in different way?

Question by Student

I don’t know how to write title for this question. Anyway this is the scenario ..

I have a table like this

Person

id | username | firstname | lastname
 1 |    ab    |     Aaaa  |    Bbbb
 2 |    yz    |     Yyyy  |    Zzzz

I use following URL to show person profile:

example.com/person/profile/index?id=1   // Show person 1 profile
example.com/person/profile/index?id=1   // Show person 2 profile

Here: person is module, profile is controller and index is action used to get and show user profile using param id

Above scenario is working perfectly.

Question:

Now I want to use following URLs to get user profile using usernames

example.com/person/profile/ab   // Show person 1 profile
example.com/person/profile/yz   // Show person 2 profile

Any idea ??

Thanks

Answer by Starx

By default you don’t need to do anything. Just add /name/THENAME to the last of the url.

Then,

  1. Get the value of the name

    $name = $this -> _request -> getParam('name');
    
  2. Use that values to extract the id from the database

  3. And use it as you want
...

Please fill the form - I will response as fast as I can!