Page 1 of 1

Getting content_id where module is embedded in backend

Posted: Wed Apr 20, 2011 1:00 pm
by mydom
Hi,

i'm about to modify the news-module to work together with serveral apis. Therefor I need to generate the url of the detailpages after adding an article in backend.

Detaillinks in the newsmodule are build like this:
news/*NEWSID*/*PAGEID*/*NEWSTITLE*/
index.php?mact=News,cntnt01,detail,0&cntnt01articleid=*NEWSID*&cntnt01returnid=*PAGEID*
The part missing is *PAGEID* which is the content_id of the frontend-page where the news-module is embedded.
These links could be used with PAGEID=0 so that the default page is loaded.
BUT: It could be a problem if the default-page has another template than the news-page. The news-page isn't select in the menu too.

One way would be:

Code: Select all

SELECT content_id FROM cms_content_props WHERE content  LIKE '%{News%'
This isn't very nice an error-prone.

Is there another possibility to get the content-ID of the frontend-page in which the news-module is currently embedded?
Is this frontend-page somehow connected with the backend?

Does someone has another idee how to solve that problem?
I would appreciate any advice.

Re: Getting content_id where module is embedded in backend

Posted: Wed Apr 20, 2011 2:44 pm
by RonnyK
I thought that frontendpages, had $page_alias and $page_id f.e. available...

Ronny

Re: Getting content_id where module is embedded in backend

Posted: Thu Apr 21, 2011 9:46 am
by mydom
RonnyK wrote:I thought that frontendpages, had $page_alias and $page_id f.e. available...

Ronny
Yes they are available at frontendpages. But i don't need them at frontendpages ;)

This is what i'm doing right now in action.addarticle.php of the newsmodule:

Code: Select all

$query = "SELECT content_id FROM ".cms_db_prefix()."content_props WHERE content LIKE '%{News%'";
$pageid = $db->GetOne($query);

if ($config['url_rewriting'] == 'mod_rewrite') {
  $aliasedTitle = munge_string_to_url($title);
  $url = $config['root_url'].'/news/'.$articleid.'/'.$pageid.'/'.$aliasedTitle.'/';
} else {
  $url = $config['root_url'].'/index.php?mact=News,cntnt01,detail,0&cntnt01articleid='.$articleid.'cntnt01returnid='.$pageid;
}
It works but it could be nicer ;D