# -*- encoding : utf-8 -*-
class Public::MenuItemsController < ApplicationController
  
	layout "public"
	def show
    #@admin = true if params[:admin]
    
    if params[:url]
      @menu_item = MenuItem.find_by_permalink(params[:url])
    else
    
      @menu_item = MenuItem.find_by_slug("accueil")
    
    
    end
    
    
		
		if @menu_item
		  
			if !@menu_item.enabled
				redirect_to "/404.html"
		
			elsif @menu_item.menu_content_type == "MenuAlias"
				if @menu_item.menu_content.menu_item
					redirect_to menu_item_path(:url => @menu_item.menu_content.menu_item_alias.permalink)
				else
					redirect_to "/404.html"
				end
	
		
			elsif @menu_item.menu_content_type == "Page"
			
			
				@page = @menu_item.menu_content
			
				@title = @page.title
			  @accueil= true if @menu_item.slug == "accueil"
			
			end
		else
			@menu_item = MenuItem.find_by_slug("404")
			
		end
  	end

    
end
