name or mm tid of containing page?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

name or mm tid of containing page?

grahamtk
This post has NOT been accepted by the mailing list yet.
Hi!
I have searched for occurences of nid in mm_api.inc and this forum for "page of node" and " containing page, but cannot find what I am looking for. A way to get the containing page of a node, preferably by nid. I see how this may return more than one mmtid or more than one page, but, nevertheless.
In the case of multiple pages, would there be a way to determine the first or the most prominent page of the node? ( length of path or date of first assignment)

thanks!
Øyvind Graham.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: name or mm tid of containing page?

McBride, Ian S.
I occasionally need to do something like this. I wrote a very, very naïve utility function for it:

/**
 * Get the full site URL for a node based on its node id or, if it appears on more the one page, its nid and mmtid.
 *
 * @param $nid
 *   The node id of the node to retrieve.
 * @param $mmtid
 *   Optionally, a mmtid of a page used to bound the search for the node.
 */
function middlebury_monster_menus_get_nid_url($nid, $mmtid = NULL) {
  $url = 'node/' . $nid;
  $tid = NULL;

  if ($mmtid == NULL) {
    $tid = db_result(db_query_range('SELECT n.mmtid FROM {mm_node2tree} n WHERE n.nid = %d', array($nid), 0, 1));
  }
  else {
    $tid = db_result(db_query_range('SELECT n.mmtid FROM {mm_node2tree} n JOIN {mm_tree} m ON (m.mmtid = n.mmtid) JOIN {mm_tree_parents} t ON (m.mmtid = t.mmtid) WHERE n.nid = %d AND (m.mmtid = %d OR m.parent = %d OR t.parent = %d)', array($nid, $mmtid, $mmtid, $mmtid), 0, 1));
  }

  if ($tid) {
    $tid = 'mm/' . $tid;
    custom_url_rewrite_outbound($tid, $options, $tid);
    $url = $tid;
  }

  return $url;
}

If you get rid of the db_query_range wrapper, you can have it return multiple results and then handle those however you'd like.

On 8/21/14, 8:46 AM, "grahamtk" <[hidden email]<mailto:[hidden email]>> wrote:

Hi!
I have searched for occurences of nid in mm_api.inc and this forum for "page
of node" and " containing page, but cannot find what I am looking for. A way
to get the containing page of a node, preferably by nid. I see how this may
return more than one mmtid or more than one page, but, nevertheless.
In the case of multiple pages, would there be a way to determine the first
or the most prominent page of the node? ( length of path or date of first
assignment)

thanks!
Øyvind Graham.



--
View this message in context: http://monster-menus.2910260.n2.nabble.com/name-or-mm-tid-of-containing-page-tp7572946.html
Sent from the Monster Menus mailing list archive at Nabble.com.

---
You are currently subscribed to monster_menus as: [hidden email]<mailto:[hidden email]>.
To unsubscribe click here: http://lists.middlebury.edu/u?id=685439.7e7cbccf9bb225cf8471bffe1cb67503&n=T&l=monster_menus&o=705303
or send a blank email to [hidden email]<mailto:[hidden email]>


---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=705304
or send a blank email to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: name or mm tid of containing page?

Jay Dansand
In reply to this post by grahamtk
For turning NIDs into MMTID lists, we use mm_content_get_by_nid() for this (it's in mm_content.inc).  I'm pretty sure they're returned in the order they appear in the node's page assignment settings.


-- 
Jay Dansand '08
Senior Web Application Developer
Technology Services, Seeley G. Mudd Library
Lawrence University
Appleton, WI
920-832-6585
[hidden email]


-----Original Message-----
From: McBride, Ian S. [mailto:[hidden email]]
Sent: Thursday, August 21, 2014 7:51 AM
To: Monster Menus Development
Subject: Re: name or mm tid of containing page?

I occasionally need to do something like this. I wrote a very, very naïve utility function for it:

/**
 * Get the full site URL for a node based on its node id or, if it appears on more the one page, its nid and mmtid.
 *
 * @param $nid
 *   The node id of the node to retrieve.
 * @param $mmtid
 *   Optionally, a mmtid of a page used to bound the search for the node.
 */
function middlebury_monster_menus_get_nid_url($nid, $mmtid = NULL) {
  $url = 'node/' . $nid;
  $tid = NULL;

  if ($mmtid == NULL) {
    $tid = db_result(db_query_range('SELECT n.mmtid FROM {mm_node2tree} n WHERE n.nid = %d', array($nid), 0, 1));
  }
  else {
    $tid = db_result(db_query_range('SELECT n.mmtid FROM {mm_node2tree} n JOIN {mm_tree} m ON (m.mmtid = n.mmtid) JOIN {mm_tree_parents} t ON (m.mmtid = t.mmtid) WHERE n.nid = %d AND (m.mmtid = %d OR m.parent = %d OR t.parent = %d)', array($nid, $mmtid, $mmtid, $mmtid), 0, 1));
  }

  if ($tid) {
    $tid = 'mm/' . $tid;
    custom_url_rewrite_outbound($tid, $options, $tid);
    $url = $tid;
  }

  return $url;
}

If you get rid of the db_query_range wrapper, you can have it return multiple results and then handle those however you'd like.

On 8/21/14, 8:46 AM, "grahamtk" <[hidden email]<mailto:[hidden email]>> wrote:

Hi!
I have searched for occurences of nid in mm_api.inc and this forum for "page
of node" and " containing page, but cannot find what I am looking for. A way
to get the containing page of a node, preferably by nid. I see how this may
return more than one mmtid or more than one page, but, nevertheless.
In the case of multiple pages, would there be a way to determine the first
or the most prominent page of the node? ( length of path or date of first
assignment)

thanks!
Øyvind Graham.



--
View this message in context: http://monster-menus.2910260.n2.nabble.com/name-or-mm-tid-of-containing-page-tp7572946.html
Sent from the Monster Menus mailing list archive at Nabble.com.

---
You are currently subscribed to monster_menus as: [hidden email]<mailto:[hidden email]>.
To unsubscribe click here: http://lists.middlebury.edu/u?id=685439.7e7cbccf9bb225cf8471bffe1cb67503&n=T&l=monster_menus&o=705303
or send a blank email to [hidden email]<mailto:[hidden email]>


---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=849053.214f550f57fa54a976b5f2d087b6d379&n=T&l=monster_menus&o=705304
or send a blank email to [hidden email]

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=705305
or send a blank email to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: name or mm tid of containing page?

McBride, Ian S.
In reply to this post by grahamtk
Obviously, use Jay's suggestion. I wasn't even aware that was in the
Drupal 7 version of MM and now am going to go back and replace all the
calls to my terrible utility function with it.

On 8/21/14, 8:54 AM, "Jay Dansand" <[hidden email]> wrote:

>For turning NIDs into MMTID lists, we use mm_content_get_by_nid() for
>this (it's in mm_content.inc).  I'm pretty sure they're returned in the
>order they appear in the node's page assignment settings.
>
>
>--
>Jay Dansand '08
>Senior Web Application Developer
>Technology Services, Seeley G. Mudd Library
>Lawrence University
>Appleton, WI
>920-832-6585
>[hidden email]
>
>
>-----Original Message-----
>From: McBride, Ian S. [mailto:[hidden email]]
>Sent: Thursday, August 21, 2014 7:51 AM
>To: Monster Menus Development
>Subject: Re: name or mm tid of containing page?
>
>I occasionally need to do something like this. I wrote a very, very naïve
>utility function for it:
>
>/**
> * Get the full site URL for a node based on its node id or, if it
>appears on more the one page, its nid and mmtid.
> *
> * @param $nid
> *   The node id of the node to retrieve.
> * @param $mmtid
> *   Optionally, a mmtid of a page used to bound the search for the node.
> */
>function middlebury_monster_menus_get_nid_url($nid, $mmtid = NULL) {
>  $url = 'node/' . $nid;
>  $tid = NULL;
>
>  if ($mmtid == NULL) {
>    $tid = db_result(db_query_range('SELECT n.mmtid FROM {mm_node2tree} n
>WHERE n.nid = %d', array($nid), 0, 1));
>  }
>  else {
>    $tid = db_result(db_query_range('SELECT n.mmtid FROM {mm_node2tree} n
>JOIN {mm_tree} m ON (m.mmtid = n.mmtid) JOIN {mm_tree_parents} t ON
>(m.mmtid = t.mmtid) WHERE n.nid = %d AND (m.mmtid = %d OR m.parent = %d
>OR t.parent = %d)', array($nid, $mmtid, $mmtid, $mmtid), 0, 1));
>  }
>
>  if ($tid) {
>    $tid = 'mm/' . $tid;
>    custom_url_rewrite_outbound($tid, $options, $tid);
>    $url = $tid;
>  }
>
>  return $url;
>}
>
>If you get rid of the db_query_range wrapper, you can have it return
>multiple results and then handle those however you'd like.
>
>On 8/21/14, 8:46 AM, "grahamtk"
><[hidden email]<mailto:[hidden email]>> wrote:
>
>Hi!
>I have searched for occurences of nid in mm_api.inc and this forum for
>"page
>of node" and " containing page, but cannot find what I am looking for. A
>way
>to get the containing page of a node, preferably by nid. I see how this
>may
>return more than one mmtid or more than one page, but, nevertheless.
>In the case of multiple pages, would there be a way to determine the first
>or the most prominent page of the node? ( length of path or date of first
>assignment)
>
>thanks!
>Øyvind Graham.
>
>
>
>--
>View this message in context:
>http://monster-menus.2910260.n2.nabble.com/name-or-mm-tid-of-containing-pa
>ge-tp7572946.html
>Sent from the Monster Menus mailing list archive at Nabble.com.
>
>---
>You are currently subscribed to monster_menus as:
>[hidden email]<mailto:[hidden email]>.
>To unsubscribe click here:
>http://lists.middlebury.edu/u?id=685439.7e7cbccf9bb225cf8471bffe1cb67503&n
>=T&l=monster_menus&o=705303
>or send a blank email to
>[hidden email]<
>mailto:[hidden email]
>ry.edu>
>
>
>---
>You are currently subscribed to monster_menus as:
>[hidden email].
>To unsubscribe click here:
>http://lists.middlebury.edu/u?id=849053.214f550f57fa54a976b5f2d087b6d379&n
>=T&l=monster_menus&o=705304
>or send a blank email to
>[hidden email]
>
>---
>You are currently subscribed to monster_menus as: [hidden email].
>To unsubscribe click here:
>http://lists.middlebury.edu/u?id=685439.7e7cbccf9bb225cf8471bffe1cb67503&n
>=T&l=monster_menus&o=705305
>or send a blank email to
>[hidden email]


---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=705306
or send a blank email to [hidden email]
Loading...