Add Page external_link
This commit is contained in:
		
							parent
							
								
									a4c900af4d
								
							
						
					
					
						commit
						32fdf99833
					
				| 
						 | 
				
			
			@ -6,7 +6,9 @@ class PagesController < ApplicationController
 | 
			
		|||
    @page = Page.find_by_name(params[:page_name])
 | 
			
		||||
    @layout = @page.layout
 | 
			
		||||
    
 | 
			
		||||
    if @page
 | 
			
		||||
    if @page && @page.external_link
 | 
			
		||||
      redirect_to @page.external_link
 | 
			
		||||
    elsif @page
 | 
			
		||||
       @page_content = Liquid::Template.parse(@page.content).render
 | 
			
		||||
       @layout_content = (@page.layout)? @layout.content : "{{page_content}}"
 | 
			
		||||
       render :text => Liquid::Template.parse(@layout_content).render( 'page_content' => @page_content )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,6 +5,7 @@ class Page < CouchFoo::Base
 | 
			
		|||
   property :content, String
 | 
			
		||||
   property :layout_id, String
 | 
			
		||||
   property :layout_name, String
 | 
			
		||||
   property :external_link, String
 | 
			
		||||
   property :position, Integer
 | 
			
		||||
   property :is_published, Boolean
 | 
			
		||||
   
 | 
			
		||||
| 
						 | 
				
			
			@ -30,12 +31,12 @@ class Page < CouchFoo::Base
 | 
			
		|||
   protected
 | 
			
		||||
   
 | 
			
		||||
   def setup_default_value
 | 
			
		||||
     unless self.position
 | 
			
		||||
     if self.position.blank?
 | 
			
		||||
       max_page = Page.last( :use_key => 'position')
 | 
			
		||||
       self.position = (max_page)? max_page.position.to_i + 1 : 1
 | 
			
		||||
     end
 | 
			
		||||
     
 | 
			
		||||
     unless self.parent_page_id
 | 
			
		||||
     if self.parent_page_id.blank?
 | 
			
		||||
       self.parent_page_id = "root"
 | 
			
		||||
     end
 | 
			
		||||
   end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,3 +17,8 @@
 | 
			
		|||
<%= f.label :is_published, "Is Published" %>
 | 
			
		||||
<%= f.radio_button :is_published, true %>Yes <%= f.radio_button :is_published, false %> No
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
<p>
 | 
			
		||||
<%= f.label :external_link, "External Link" %>
 | 
			
		||||
<%= f.text_field :external_link %>
 | 
			
		||||
</p>
 | 
			
		||||
| 
						 | 
				
			
			@ -16,3 +16,4 @@
 | 
			
		|||
<br />
 | 
			
		||||
 | 
			
		||||
<%= link_to 'New snippets', new_admin_snippet_path, :class => 'button positive' %>
 | 
			
		||||
<%= link_to 'New menu snippets', new_admin_snippet_path, :class => 'button positive' %>
 | 
			
		||||
		Loading…
	
		Reference in New Issue