Skip to main content
added 961 characters in body; edited tags
Source Link
mamesaye
  • 261
  • 3
  • 18

I am using the ShURLy module to create short links for nodes. I would like to be able to create the short links when nodes are published, automatically, without having to do the extra steps of clicking on the Bookmarklet which opens a new page where I create the short link by clicking on a button/link.

How can I achieve this?

update

I am using workbench so I added

function my_node_workbench_moderation_transition($node, 
$previous_state, $new_state) {
// Generate the short link when it is published.
  if ($new_state == 'published' && $previous_state != $new_state) {
    $link = my_node_create_short_link($node->nid); 
  }
}    

and the function my_node_create_short_link with shorten (shorten_url)

function my_node_create_short_link($node_id) {
 // Do not create the short link if already exists.
  $link = my_node_short_link_get($node_id);
  if ($link) {
      return $link;
  }
  else {
    $link = shorten_url(url('node/' . $node->nid, array('absolute' => TRUE)));
    // Insert the link
    my_node_short_link_insert($node->nid;, $link);
    cache_set($node->nid;, $link);
    return $link;
  }

}

I am using the ShURLy module to create short links for nodes. I would like to be able to create the short links when nodes are published, automatically, without having to do the extra steps of clicking on the Bookmarklet which opens a new page where I create the short link by clicking on a button/link.

How can I achieve this?

I am using the ShURLy module to create short links for nodes. I would like to be able to create the short links when nodes are published, automatically, without having to do the extra steps of clicking on the Bookmarklet which opens a new page where I create the short link by clicking on a button/link.

How can I achieve this?

update

I am using workbench so I added

function my_node_workbench_moderation_transition($node, 
$previous_state, $new_state) {
// Generate the short link when it is published.
  if ($new_state == 'published' && $previous_state != $new_state) {
    $link = my_node_create_short_link($node->nid); 
  }
}    

and the function my_node_create_short_link with shorten (shorten_url)

function my_node_create_short_link($node_id) {
 // Do not create the short link if already exists.
  $link = my_node_short_link_get($node_id);
  if ($link) {
      return $link;
  }
  else {
    $link = shorten_url(url('node/' . $node->nid, array('absolute' => TRUE)));
    // Insert the link
    my_node_short_link_insert($node->nid;, $link);
    cache_set($node->nid;, $link);
    return $link;
  }

}

removed tags from the title
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

7 create Create short link automatically with ShURLy

I am using the ShURLy module to create short links for my nodes. I I would like to be able to create the short links on node publish automatically ...when nodes are published, automatically, without having to do the extra steps of clicking on the Bookmarklet which openopens a new page where youI create the short link by clicking on a button/link. How do

How can I do itachieve this?

7 create short link automatically with ShURLy

I am using ShURLy to create short links for my nodes. I would like to be able to create the short links on node publish automatically ... without having to do the extra steps of clicking on the Bookmarklet which open a new page where you create the short link by clicking on a button/link. How do I do it?

Create short link automatically with ShURLy

I am using the ShURLy module to create short links for nodes. I would like to be able to create the short links when nodes are published, automatically, without having to do the extra steps of clicking on the Bookmarklet which opens a new page where I create the short link by clicking on a button/link.

How can I achieve this?

Source Link
mamesaye
  • 261
  • 3
  • 18

7 create short link automatically with ShURLy

I am using ShURLy to create short links for my nodes. I would like to be able to create the short links on node publish automatically ... without having to do the extra steps of clicking on the Bookmarklet which open a new page where you create the short link by clicking on a button/link. How do I do it?