Modify the Your Content Page

15 replies [Last post]
bradbrad
Offline
Joined: 04/02/2011
Status: 
Answered

Hi Leighton

Please explain to me how to modify the Your Content area, I want to include a column that for the node ID (that links to the node).

Leighton Whiting
Offline
Joined: 06/02/2009
Doesn't the node title

Doesn't the node title already link to the node? In Drupal 7 it would be easy to modify with the hook_page_alter, but for Drupal 6 there is no easy way to alter it.

Sincerely,

Leighton Whiting

bradbrad
Offline
Joined: 04/02/2011
Thanks Leighton for the

Thanks Leighton for the reply. Yes it does, my client just want to have the NID present in the list so that people can easy find it (he calls it a listing ID). So what would you recommend i do? Create a View to display it instead, and create a redirect so that /user/me/my-content goes to the new page?

Leighton Whiting
Offline
Joined: 06/02/2009
Brad, Yes, give Views a try.

Brad,

Yes, give Views a try. You can set up the View so that it will appear on the User Account as a tab and get the user id as an argument from the url. Then you can remove the 'view own content' permission to hide the original content tab. Hope that helps!

-Leighton

bradbrad
Offline
Joined: 04/02/2011
HI Leighton   Im busy doing

HI Leighton

 

Im busy doing it now in Views, and so far so good. Im just trying to recreate the "expiring in so many days" column but have hit a blank. do you know of any way i can get this to display?

 

Many thanks

Leighton Whiting
Offline
Joined: 06/02/2009
Brad, You will need to use

Brad,

You will need to use the Views Custom Field (http://drupal.org/project/views_customfield) module for this, and put in the following snippet:

  1. <?php
  2.  
  3. $pp_node = ms_paypublish_load_node_nid($nid);
  4.  
  5. print ms_paypublish_get_expires_string($pp_node);
  6.  
  7. ?>

There are lots of other useful fields in the pp_node object.

Sincerely,

Leighton Whiting

bradbrad
Offline
Joined: 04/02/2011
Hi Leighton Thanks for that.

Hi Leighton

Thanks for that. I installed the module, created a new field, selected custom field, PHP code, and pasted the snippet into the value box, but unfortunately its not displaying? it just displays as blank? Any ideas what im doing wrong?

Please also let me know what code i must put into to display the "Edit | Promote / Extend" that normally appears under actions.

 

Many thanks

Leighton Whiting
Offline
Joined: 06/02/2009
It's possible that the $nid

It's possible that the $nid variable is not set. It's been a while since I've done this. I think if you include the node id field in the view and put it above the other fields in order, then it will be available like this:

  1. $data->nid

Give that a try instead of just $nid

bradbrad
Offline
Joined: 04/02/2011
Im a bit confused by what you

Im a bit confused by what you mean? so the code would then be

 

  <?php     $pp_node = ms_paypublish_load_node_nid(<span style="color: #000000"><span style="color: #0000BB">$data</span><span style="color: #007700">-></span><span style="color: #0000BB">nid</span></span>);     print ms_paypublish_get_expires_string($pp_node);     ?>

 

I tried the above and got a parse error? Sorry, im just not understanding you.

 

Please also let me know how to display the edit | Promote/extend link

Leighton Whiting
Offline
Joined: 06/02/2009
Sorry, I pasted it wrong. It

Sorry, I pasted it wrong. It is just $data->nid instead of $nid

-Leighton

Leighton Whiting
Offline
Joined: 06/02/2009
Actions are a bit more

Actions are a bit more complex, because they are dependant on the status of the pp_node. If it is active, it should show X action, etc.

Here is an example:

  1. switch ($pp_node->status) {
  2.       case 0: // Inactive
  3.         $actions[] = l(t('Publish'), 'ms_paypublish/publish/'. $pp_node->nid);
  4.       break;
  5.      
  6.       case 1: // Published with Expiration
  7.         if ($plan->recurring) {
  8.           if ($cancel_url = ms_core_get_cancel_url($order)) {
  9.             $actions[] = l(t('Cancel'), $cancel_url, array('query' => drupal_get_destination()));
  10.           }
  11.         }
  12.         elseif ($pp_node->expiration_date) {
  13.             // Don't show the Promote / Extend link if the user doesn't have permission
  14.             if (user_access('renew own pay to publish nodes')) {
  15.             $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  16.             }
  17.         }
  18.       break;
  19.      
  20.       case 2: // Awaiting Admin Approval
  21.        
  22.       break;
  23.      
  24.       case 3: // Not Yet Published
  25.           // Don't show the Promote / Extend link if the user doesn't have permission
  26.         if (user_access('renew own pay to publish nodes')) {
  27.           $actions[] = l(t('Publish'), 'ms_paypublish/publish/'. $pp_node->nid);
  28.         }
  29.       break;
  30.      
  31.       case 4: // Published Without Expiration
  32.        
  33.       break;
  34.        
  35.       case 5: // Awaiting Admin Approval without Expiration
  36.        
  37.       break;
  38.      
  39.       case 6: // Cancelled (for recurring plans)
  40.  
  41.       break;
  42.      
  43.       case 7: // Expiring Soon
  44.         if ($plan->recurring) {
  45.           // Do nothing
  46.         }
  47.         else {
  48.             // Don't show the Promote / Extend link if the user doesn't have permission
  49.           if (user_access('renew own pay to publish nodes')) {
  50.             $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  51.           }
  52.         }
  53.       break;
  54.      
  55.       case 8: // End of Term
  56.           // Don't show the Promote / Extend link if the user doesn't have permission
  57.         if (user_access('renew own pay to publish nodes')) {
  58.           $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  59.         }
  60.       break;
  61.      
  62.       case 9: // Denied
  63.  
  64.           break;
  65.     }
  66. print implode($actions, ' | ');

Hope that helps!

-Leighton

bradbrad
Offline
Joined: 04/02/2011
Thanks Leighton   I was able

Thanks Leighton

 

I was able to get it to display the expires in date.

 

I tried to add the "actions" code. 1st i got a lot of coding just being displayed, then i put it in <?php?> and it displayed on the link: Publish (even though the nodes were published?), all linking to /ms_paytopublish/publish/

Here is the code as i put it in:

 

  1. &nbsp;&nbsp; <?php
  2. &nbsp;switch ($pp_node->status) {
  3. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 0: // Inactive
  4. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $actions[] = l(t('Publish'), 'ms_paypublish/publish/'. $pp_node->nid);
  5. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  6. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  7. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 1: // Published with Expiration
  8. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($plan->recurring) {
  9. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($cancel_url = ms_core_get_cancel_url($order)) {
  10. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $actions[] = l(t('Cancel'), $cancel_url, array('query' => drupal_get_destination()));
  11. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  12. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  13. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; elseif ($pp_node->expiration_date) {
  14. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Don't show the Promote / Extend link if the user doesn't have permission
  15. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (user_access('renew own pay to publish nodes')) {
  16. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  17. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  18. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  19. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  20. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  21. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 2: // Awaiting Admin Approval
  22. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  23. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  24. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  25. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 3: // Not Yet Published
  26. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Don't show the Promote / Extend link if the user doesn't have permission
  27. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (user_access('renew own pay to publish nodes')) {
  28. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $actions[] = l(t('Publish'), 'ms_paypublish/publish/'. $pp_node->nid);
  29. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  30. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  31. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  32. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 4: // Published Without Expiration
  33. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  34. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  35. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  36. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 5: // Awaiting Admin Approval without Expiration
  37. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  38. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  39. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  40. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 6: // Cancelled (for recurring plans)
  41. &nbsp;&nbsp;&nbsp; &nbsp;
  42. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  43. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  44. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 7: // Expiring Soon
  45. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($plan->recurring) {
  46. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Do nothing
  47. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  48. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else {
  49. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Don't show the Promote / Extend link if the user doesn't have permission
  50. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (user_access('renew own pay to publish nodes')) {
  51. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  52. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  53. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  54. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  55. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  56. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 8: // End of Term
  57. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Don't show the Promote / Extend link if the user doesn't have permission
  58. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (user_access('renew own pay to publish nodes')) {
  59. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  60. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  61. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  62. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
  63. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case 9: // Denied
  64. &nbsp;&nbsp;&nbsp; &nbsp;
  65. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;
  66. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
  67. &nbsp;&nbsp;&nbsp; print implode($actions, ' | ');
  68. ?>

 

bradbrad
Offline
Joined: 04/02/2011
sorry, 3rd time luck

  1. <?php
  2. switch ($pp_node->status) {
  3. case 0: // Inactive
  4. $actions[] = l(t('Publish'), 'ms_paypublish/publish/'. $pp_node->nid);
  5. break;
  6.  
  7. case 1: // Published with Expiration
  8. if ($plan->recurring) {
  9. if ($cancel_url = ms_core_get_cancel_url($order)) {
  10. $actions[] = l(t('Cancel'), $cancel_url, array('query' => drupal_get_destination()));
  11. }
  12. }
  13. elseif ($pp_node->expiration_date) {
  14. // Don't show the Promote / Extend link if the user doesn't have permission
  15. if (user_access('renew own pay to publish nodes')) {
  16. $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  17. }
  18. }
  19. break;
  20.  
  21. case 2: // Awaiting Admin Approval
  22.  
  23. break;
  24.  
  25. case 3: // Not Yet Published
  26. // Don't show the Promote / Extend link if the user doesn't have permission
  27. if (user_access('renew own pay to publish nodes')) {
  28. $actions[] = l(t('Publish'), 'ms_paypublish/publish/'. $pp_node->nid);
  29. }
  30. break;
  31.  
  32. case 4: // Published Without Expiration
  33.  
  34. break;
  35.  
  36. case 5: // Awaiting Admin Approval without Expiration
  37.  
  38. break;
  39.  
  40. case 6: // Cancelled (for recurring plans)
  41.  
  42. break;
  43.  
  44. case 7: // Expiring Soon
  45. if ($plan->recurring) {
  46. // Do nothing
  47. }
  48. else {
  49. // Don't show the Promote / Extend link if the user doesn't have permission
  50. if (user_access('renew own pay to publish nodes')) {
  51. $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  52. }
  53. }
  54. break;
  55.  
  56. case 8: // End of Term
  57. // Don't show the Promote / Extend link if the user doesn't have permission
  58. if (user_access('renew own pay to publish nodes')) {
  59. $actions[] = l(t('Promote / Extend'), 'ms_paypublish/publish/'. $pp_node->nid);
  60. }
  61. break;
  62.  
  63. case 9: // Denied
  64.  
  65. break;
  66. }
  67. print implode($actions, ' | ');
  68. ?>

Leighton Whiting
Offline
Joined: 06/02/2009
Be sure to also load the

Be sure to also load the $pp_node before the switch statement, and also load the $plan and the $order too.

Example:

  1. $pp_node = ms_paypublish_load_node_nid($data->nid);
  2. $order = ms_core_order_load($pp_node->oid);
  3. $plan = ms_paypublish_load_plan($pp_node->pid);

Hope that helps!

-Leighton

bradbrad
Offline
Joined: 04/02/2011
Worked like a charm! Thank

Worked like a charm! Thank you so much leighton!

Quick question regarding this custom views. Would it be possible for me to add a link to make use of a ready made action (from actions) (want to use the node convert module and its actions)? I know its off topic, but thought i might as well ask :)

Leighton Whiting
Offline
Joined: 06/02/2009
I don't know much about Node

I don't know much about Node Convert, but if they have a callback url then it may be possible.

-Leighton

Twitter Feed