We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Creating PermaLink for posts in site

Development and Programming

pluginstla's avatar
pluginstla
2 posts
16 years ago
pluginstla's avatar pluginstla

Im trying to make a module that will generate a xml file of all the links in the site,

much like a RSS feed but with just the permalinks for all the pages in the site.

My problem is i can’t find a method that will generate the Advertised Permalink that when templates are involved

For example

http://www.domain.com/site/my_page is what im creating using

$FNS->create_url('site/'.$post['url_title']);

This works but not when im working with templates

http://www.domain.com/template/page/my_page is the permalink that im looking for, but how can I create this. below is a short example of my select and url creation. I have spent a great deal of time looking into this without resolution.

$results = $DB->query("SELECT DISTINCT(wt.entry_id) AS id, wt.title AS title, wt.url_title AS  url_title, wt.weblog_id, wt.entry_date AS entry_date, exp_weblog_data.field_id_2 AS body
                FROM   exp_weblog_titles wt, exp_weblog_data,exp_weblogs
                WHERE wt.entry_id = exp_weblog_data.entry_id AND wt.status != 'closed'");

        
echo "<link>" . $FNS->create_url('site/'.$post['url_title'], 0) . "</link>\n";

It seems like there should be some sort of permalink function, most other engines have something similar

I was looking at the LG site map plugin demo and it looks like they require you to create permalink that will be used in the sitemap via a custom feild, which seems silly.

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz

I would probably use the comment_url from exp_weblogs in conjunction with the url_title.

       
pluginstla's avatar
pluginstla
2 posts
16 years ago
pluginstla's avatar pluginstla

what do you mean in conjunction? if comment_url exists use it ? otherwise use blog_url?

something like this ?

$results = $DB->query("SELECT DISTINCT(wt.entry_id) AS id, exp_weblogs.comment_url, wt.title AS title, wt.url_title AS  url_title, wt.weblog_id, wt.entry_date AS entry_date, exp_weblog_data.field_id_2 AS body
                FROM   exp_weblog_titles wt, exp_weblogs.blog_url, exp_weblog_data,exp_weblogs
                WHERE wt.entry_id = exp_weblog_data.entry_id AND wt.status != 'closed'");


foreach($results->result as $post){
    //remove comments info if it exists
    $perm_url=str_replace('/comments/','',$post['comment_url']);
    //if empty comment url add blogurl instead
    if (empty($perm_url)) $perm_url=$post['blog_url'];
            
    //add the title to the base url to get permalink
    $url=$FNS->remove_double_slashes($perm_url.'/'.$post['url_title']);

   echo $url.",";
}
       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz

No, the comment_url usually points to the template used for the permalink. Add the url_title for the complete link.

Honestly, I haven’t quite understood yet why you have to resort to PHP at all for this task.

       
pluginstla's avatar
pluginstla
2 posts
16 years ago
pluginstla's avatar pluginstla

yah i found it in cp.publisher.php link 4511 thanks for your help

$body = $this->_convert_forum_tags(str_replace('{permalink}', 
                                                               $FNS->remove_double_slashes($comment_url.'/'.$url_title.'/'), 
                                                            $IN->GBL('forum_body')));
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.