To participate you must create an account on apostrophenow.org. If you have already done so, click Login.
Changeset 1095
- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r982
|
r1095
|
|
| 5 | 5 | twoColumnTemplate: Two Column |
| 6 | 6 | # bannerTemplate: Banner Template # Dan, I wanna make a banner template bundled with the plugin |
| | 7 | comments: false |
-
|
r1053
|
r1095
|
|
| 17 | 17 | * This function attempts to find the "best" engine to route a given post to. |
| 18 | 18 | */ |
| 19 | | public function findBestEngineRoute() |
| | 19 | public function findBestEngine() |
| 20 | 20 | { |
| 21 | | $engines = aPageTable::createQuery()->addWhere('engine = aBlog')->execute(); |
| | 21 | $engines = Doctrine::getTable('aPage')->createQuery() |
| | 22 | ->addWhere('engine = ?', 'aBlog') |
| | 23 | ->execute(); |
| 22 | 24 | |
| 23 | 25 | if(count($engines) == 0) |
| 24 | 26 | return ''; |
| 25 | 27 | else if(count($engines) == 1) |
| 26 | | return url_for('@aPage?slug='.$engines[0]['slug']); |
| | 28 | return $engines[0]; |
| 27 | 29 | |
| 28 | 30 | //When there are more than one engine page we need to use some heuristics to |
| … |
… |
|
| 35 | 37 | |
| 36 | 38 | if(count($catIds) < 1) |
| 37 | | return url_for('@aPage?slug='.$engines[0]['slug']); |
| | 39 | return $engines[0]; |
| 38 | 40 | |
| 39 | 41 | $best = array(0, ''); |
| | 42 | |
| 40 | 43 | foreach($engines as $engine) |
| 41 | 44 | { |
| 42 | 45 | $score = 0; |
| 43 | | foreach($engine->blogCategories as $category) |
| | 46 | foreach($engine->BlogCategories as $category) |
| 44 | 47 | { |
| 45 | 48 | if(isset($catIds[$category['id']])) |
| … |
… |
|
| 48 | 51 | if($score > $best[0]) |
| 49 | 52 | { |
| 50 | | $best = array($score, url_for('@aPage?slug='.$engine['slug'])); |
| | 53 | $best = $engine; |
| 51 | 54 | } |
| 52 | 55 | } |
| 53 | 56 | |
| 54 | | return $best[1]; |
| | 57 | return $best; |
| 55 | 58 | } |
| 56 | 59 | |
-
|
r1003
|
r1095
|
|
| 35 | 35 | <h6>Permalink:</h6> |
| 36 | 36 | <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 ?> |
| 38 | 38 | </div> |
| 39 | 39 | <div class="a-blog-post-permalink-wrapper slug"> |
Download in other formats: