To participate you must create an account on apostrophenow.org. If you have already done so, click Login.

Changeset 3399

Show
Ignore:
Timestamp:
02/23/11 11:39:59 (15 months ago)
Author:
rande
Message:

create an aCmsRoute and introduce a hybrid mode (apostrophe url can be used with symfony action)

Location:
plugins/apostrophePlugin/branches/contribute/rande/1.5
Files:
3 added
5 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostrophePlugin/branches/contribute/rande/1.5/config/doctrine/schema.yml

    r3288 r3399  
    7373    engine: 
    7474      type: string(255) 
     75 
     76    # a code is use to reference a page inside the code, ie code=term_and_condition 
     77    # we don't need to know the url to generate the url 
     78    code: 
     79      type: varchar(32) # use to reference the page 
     80 
     81    # the related action will be handled by a symfony action class but we need the page 
     82    # in the menu 
     83    skip_on_url_match: 
     84      type: boolean 
     85      default: false 
     86     
    7587  indexes: 
    7688    slugindex: 
  • plugins/apostrophePlugin/branches/contribute/rande/1.5/config/routing.yml.sample

    r4 r3399  
    11# Special case for the home page 
    22 
    3 homepage: 
    4   url:  / 
    5   param: { module: a, action: show, slug: / } 
    6  
    7 # The non-CMS actions of your project, and the admin actions of the CMS 
    8 a_action: 
    9   url:   /cms/:module/:action 
    10  
    11 # Must be the LAST rule 
     3# Must be the FIRST rule 
    124a_page: 
    135  url:   /:slug 
     6  class: aCmsRoute 
     7  options: {type: object, model: aPage} 
    148  param: { module: a, action: show } 
    159  requirements: { slug: .* } 
    1610 
     11 
     12# default rules 
     13homepage: 
     14  url:   / 
     15  param: { module: a, action: show, slug: / } 
     16 
     17a_action: 
     18  url: /cms/:module/:action 
  • plugins/apostrophePlugin/branches/contribute/rande/1.5/lib/form/BaseaPageSettingsForm.class.php

    r3273 r3399  
    180180      ))); 
    181181    } 
     182 
     183    // This option allows to have an apostrophe url linked to a symfony action 
     184    $this->setWidget('skip_on_url_match', new sfWidgetFormChoice(array( 
     185      'expanded' => true, 
     186      'choices' => array(false => "No", true => "Yes"), 
     187      'default' => false 
     188    ))); 
    182189 
    183190        // Tags 
  • plugins/apostrophePlugin/branches/contribute/rande/1.5/lib/toolkit/BaseaTools.class.php

    r3320 r3399  
    3333    aNavigation::simulateNewRequest(); 
    3434  } 
     35 
     36  /** 
     37   * retrieve a page with the provided slug (create the page if the related slug does not exist) 
     38   * 
     39   * inside a symfony template file, you can define a hybrid page and use it in an area 
     40   * 
     41   * <?php $page = aTools::getHybridPage('Poll/showPollCategory/'.$poll_category->id) ?> 
     42   * 
     43   * <?php a_area('body', array( 'slug' => $page->getSlug(), 'allowed_types' => array('aText') ); ?> 
     44   * 
     45   * @param string $slug the slug related to hybrid page 
     46   */ 
     47  static public function getHybridPage($slug) 
     48  { 
     49    aTools::globalSetup(array('slug' => 'hybrid_'.$slug)); 
     50 
     51    return aTools::getCurrentPage(); 
     52  } 
    3553   
    3654  static public function cultureOrDefault($culture = false) 
     
    7694    // and not get tripped up by the default routing rule which could 
    7795    // match first if we wrote a/show  
    78     $routed_url = sfContext::getInstance()->getController()->genUrl('@a_page?slug=-PLACEHOLDER-', $absolute); 
    79     $routed_url = str_replace('-PLACEHOLDER-', $slug, $routed_url); 
     96    $routed_url = sfContext::getInstance()->getController()->genUrl('@a_page?slug='.$slug, $absolute); 
     97 
     98    // thomas : not require anymore 
     99    // $routed_url = str_replace('-PLACEHOLDER-', $slug, $routed_url); 
     100 
    80101    // We tend to get double slashes because slugs begin with slashes 
    81102    // and the routing engine wants to helpfully add one too. Fix that, 
  • plugins/apostrophePlugin/branches/contribute/rande/1.5/modules/a/templates/settingsSuccess.php

    r3254 r3399  
    7979                                </div> 
    8080                        </div> 
     81 
     82                <div class="a-form-row"> 
     83                          <h4><label><?php echo __('Hybrid Page', null, 'apostrophe') ?></label></h4> 
     84                        <div class="<?php echo $stem ?>-hybrid-page"> 
     85                                        <?php echo $form['skip_on_url_match'] ?> 
     86                                </div> 
     87                        </div> 
    8188        </div> 
    8289