Download & Extend

Fixed portfolio for all users?

Project:Stock
Version:6.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi

The module looks very useful. However, I wonder if it would be possible for the admin to set a site-wide portfolio, so all site users get to see the same set of companies. It would also be nice if the sidebar block displayed each quote/symbol in turn, including some graphic (up/down arrow, etc).

I'll be glad to beta test this feature if it's added.
--
Albert

Comments

#1

I have the same desire. I don't expect visitors to my blog to actually use the stock module, nor would I even want them to. What I really want it for is just to provide a block that I can use which shows my visitors what stocks I'm invested or interested in. I think that's what "albertc" is saying.

#2

Version:4.7.x-1.0» 6.x-1.0

If all you want is to display a block for all users, then create a new module called custom.module,

<?php
function custom_block($op = 'list', $delta = 0, $edit = array()) {
  switch (
$op) {
    case
'list':
     
$blocks[0]['info'] = t('Portfolio');
      return
$blocks;

    case
'view':
     
$block['subject'] = t('Portfolio');
      if (
module_exists('stock')) {
       
$data = stock_do_quote('short', 'IBM AAPL GOOG');
      }
     
$block['content'] = $data;

      return
$block;
  }
}
?>

Create an custom.info file like this:

name = Custom
description = Customizations for this web site
package = Custom
core = 6.x

Put them all under a new directory sites/all/modules/custom

Enable the module, and then go to admin/build/blocks and place the block where you want it to show.

That should be it.

Other features can be added, arrows, ...etc.

Post them here when you do them.

#3

I want to be able to do this on a page and not a block, I've tried setting default stocks but they just don't work. How would I take advantage of this modules great formatting on a page for all users that cannot be changed? I don't mind using PHP but I am a bit lost as to where to start.

#4

I've found I can do this by modifying line stocks.module like so:

Change 173 to:

return db_result(db_query("SELECT symbols FROM {stock} WHERE uid = 1"));

Now it will always get the stocks saved into a specifc user. Of course now it lets anyone change them.

To prevent users from saving stock quotes you can simply gut the function stock_save_user_quotes($symbols) on line 178 to look like this:

function stock_save_user_quotes($symbols) {
  global $user;
}

For some reason this still does not work.

#5

Found I could create a page manually through drupals normal interface, select a PHP input method and put lists of stocks like so, this also works in blog posts.

<?php

$dataLong
= stock_do_quote('long', 'ARAY ULTI CPN GHDX OPEN SFLY APKT RAX');

print
$dataLong;

?>
nobody click here