Functions | |
links_get_link_node_query_sql ($link_spec, $order="weight,link_title", $orphans=TRUE, $module='links') | |
links_delete_links_for_node ($node, $module='links_links') | |
links_save_links_for_node (&$node, $module='links_links', $global=FALSE) | |
links_load_links_for_node ($nid, $module='links', $lid=0, $firstonly=FALSE) |
|
Delete all the links for the specified node (object) or nid (integer) |
|
Given a link ID, URL, or URL hash, creates an SQL query to obtain brief node data for nodes that share that link's record. Columns returned from this query include: lid The link ID number (integer) url The actual (full) URL from the link record nid The node ID number (integer) node_title The node title (string) weight The weight of this link-node pairing, which determines the order when links are listed together. clicks The number of times a browser has followed this particular instance of this particular link-node association. link_title The title given to the link (string); this is the text that is displayed for the user as the title of the link. How and where it appears (on the page, mouse over, not at all...) depends on the settings of user and admin preferences. module If a specific module wants to own the link-node association, insert that module's name here. The default is 'links', which represents the entire links package collectively. Note that lid and url fields are the same on all returned rows; they are here for convenience. The optional parameter $order determines whether the outer array is ordered by the link's weight, by link_title, or by node_title. If $order is an empty string (not the default!), no ORDER BY will be added; this allows the caller more control, such as appending a WHERE clause or doing a compound ordering on multiple columns. The default orders by weight and then by link_title. Left joins are intentionally used in this query, with the deliberate possibility to return rows with NULL values in cases of (1) a link with no associated nodes, or (2) a link associated with node IDs that no longer exist. This is useful to find orphan records. To suppress this feature, set the optional parameter $orphans to FALSE (it defaults to TRUE). Note that this function returns an SQL statement but does not actually execute the query. |
|
Given a node ID, returns all of the links currently defined for that node in the database. The return value is a compound array, with the outer subscript being an integer index and the elements associative arrays with the fields lid, url, url_md5, title, clicks, and weight. For each record returned, there are actually up to *three* title fields: link_link_title the title from the main {links} record node_link_title the title, if any, from the {links_node} record link_title the node_link_title if present, or the link_link_title otherwise. This is normally the field that applications will want to use for display. If a specific link ID is provided, returns ONLY that record. If $firstonly is TRUE, returns only one record. $firstonly is provided as a convenience for handling a "goto" URL pattern from the browser that specifies nid but not lid. This is used, among other things, for legacy compatibility with weblink.module. |
|
Save all the links for the specified node (object). The links to be saved are assumed to exist as sub-arrays inside the main integer- subscripted array named $node->$module, where $module is the parameter that specifies the context for these links. Each link is an associative sub-array containing the fields 'url', 'weight', and 'link_title'. The 'url' field is self-explanatory. 'weight' will determine, when multiple links exist, their display order when the node is rendered. 'link_title' is stored as either the node-local title for the link, or as the global link title if the link is new to the catalog. 'url' is the only required field; the others have defaults. There is no equivalent function to save a single link for a node. If modules require that functionality, they should simply pass an array with only one link sub-array.
|