Getting content_id where module is embedded in backend

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
mydom
Forum Members
Forum Members
Posts: 15
Joined: Thu Jul 09, 2009 4:21 pm

Getting content_id where module is embedded in backend

Post 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.
RonnyK
Support Guru
Support Guru
Posts: 4962
Joined: Wed Oct 25, 2006 8:29 pm
Location: Raalte, the Netherlands

Re: Getting content_id where module is embedded in backend

Post by RonnyK »

I thought that frontendpages, had $page_alias and $page_id f.e. available...

Ronny
mydom
Forum Members
Forum Members
Posts: 15
Joined: Thu Jul 09, 2009 4:21 pm

Re: Getting content_id where module is embedded in backend

Post 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
Post Reply

Return to “Developers Discussion”