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

Changeset 1095

Show
Ignore:
Timestamp:
04/29/10 15:57:44 (22 months ago)
Author:
dordille
Message:

Added function aBlogPost::findBestEngine to find the most likely fit for a blogPost based on its categories. See #206.

Location:
plugins/apostropheBlogPlugin/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • plugins/apostropheBlogPlugin/trunk/config/app.yml

    r982 r1095  
    55      twoColumnTemplate: Two Column 
    66      # bannerTemplate: Banner Template # Dan, I wanna make a banner template bundled with the plugin 
     7    comments: false 
  • plugins/apostropheBlogPlugin/trunk/lib/model/doctrine/PluginaBlogPost.class.php

    r1053 r1095  
    1717   * This function attempts to find the "best" engine to route a given post to. 
    1818   */ 
    19   public function findBestEngineRoute() 
     19  public function findBestEngine() 
    2020  { 
    21     $engines = aPageTable::createQuery()->addWhere('engine = aBlog')->execute(); 
     21    $engines = Doctrine::getTable('aPage')->createQuery() 
     22      ->addWhere('engine = ?', 'aBlog') 
     23      ->execute(); 
    2224 
    2325    if(count($engines) == 0) 
    2426      return ''; 
    2527    else if(count($engines) == 1) 
    26       return url_for('@aPage?slug='.$engines[0]['slug']); 
     28      return $engines[0]; 
    2729 
    2830    //When there are more than one engine page we need to use some heuristics to 
     
    3537 
    3638    if(count($catIds) < 1) 
    37       return url_for('@aPage?slug='.$engines[0]['slug']); 
     39      return $engines[0]; 
    3840 
    3941    $best = array(0, ''); 
     42     
    4043    foreach($engines as $engine) 
    4144    { 
    4245      $score = 0; 
    43       foreach($engine->blogCategories as $category) 
     46      foreach($engine->BlogCategories as $category) 
    4447      { 
    4548        if(isset($catIds[$category['id']])) 
     
    4851      if($score > $best[0]) 
    4952      { 
    50         $best = array($score, url_for('@aPage?slug='.$engine['slug'])); 
     53        $best = $engine; 
    5154      } 
    5255    } 
    5356 
    54     return $best[1]; 
     57    return $best; 
    5558  } 
    5659 
  • plugins/apostropheBlogPlugin/trunk/modules/aBlogAdmin/templates/editSuccess.php

    r1003 r1095  
    3535                        <h6>Permalink:</h6>  
    3636                        <div class="a-blog-post-permalink-wrapper url"> 
    37                                 <span>http://site/blog/url/</span>              <?php // Dan, Can you echo the REAL URL prefix here -- I don't know how to build a URL based on the complex blog route business we are doing  ?> 
     37        <span><?php echo aTools::urlForPage($a_blog_post->findBestEngine()->getSlug()).'/' ?></span><?php // Dan, Can you echo the REAL URL prefix here -- I don't know how to build a URL based on the complex blog route business we are doing  ?> 
    3838                        </div> 
    3939                        <div class="a-blog-post-permalink-wrapper slug">