I have a custom module that returns a given alexa traffic rank for urls.
I have a cck text field in each node called field_tr that contains the code:

<?php echo AlexaRank('google.com'); ?>
(or whatever url that node happens to be referencing; so each node has a different url referenced in the code above)

ex:
Node 1
<?php echo AlexaRank('google.com'); ?>  ===>returns the value of '1'
Node 2
<?php echo AlexaRank('yahoo.com'); ?>  ===>returns the value of '4'
Node 3
<?php echo AlexaRank('drupal.org'); ?>   ===>returns the value of '463'

field_tr returns the correct traffic rank number; but this field is how the nodes have to be sorted in Views. So a node with a lower traffic rank (closer to 1) get displayed higher in the View. Problem is, it won't sort according to this field because it is code and not a set integer.

How can I configure computed field to compute this code snippet and store that end result in the db, and have it be sortable by Views? I have been trying to configure it, but no luck.

Comments

picxelplay’s picture

If I put echo AlexaRank('google.com'); in a text cck field with php input (field_tr), then create a computed field with
$node_field[0]['value'] = $node->field_tr[0]['value'];
it doesn't do anything. I need computed field to read the resulting value of field_tr, not its php code.
Any thoughts?

mmjvb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)