Recalculate without opening the post?

schacke

Member
I'm using the form article plugin. The fields 'Published' and 'Featured' are referring to calculated elements based on which usergroup the author of a post belongs to. But if I move the user to another usergroup, it doesn't have effekt on the article before i open the post and save it.

Is there anything I can do recalculate without opening the post?


//Martin
 
It the calc element is set to "Save on calc only"=no (which is the default) it's recalculating on every Fabrik load (Fabrik list, form, details). But this calculation is not stored in the DB (as long as you don't open/resave the record) so a Joomla article fetchings it's data from the DB table will see the old values.

You may add a Fabrik scheduled task to recalculate and store.
You can run this task every xxxminutes/hours... or you can run it manually after moving a user (is this done regulary?)
If you are moving the user via a Fabrik form you can add a php form plugin and do the recalc there.
 
Okay! Thats what I thougth. Can maybe you point me to, where I can read about scheduled calculations? (Searched but couldn't find it). Actually I'm not moving the user, but the member system does, when the users up- or downgrade their membership :)
 
Ah, I just found (but never tried) there's a LIST article plugin "Adds a button to the list, allowing users to update article created with the form article plug-in"
Maybe you can use this (no docu in the WIKI, so if you try and report...;))

For scheduled tasks
http://fabrikar.com/forums/index.php?wiki/scheduled-task-plugins/
You would need to create a php script to update the #_content table directly.
http://fabrikar.com/forums/index.php?wiki/php-scheduled-task/
http://fabrikar.com/forums/index.php?wiki/common-php-tasks/
 
Thank you so much. I will try to get the scheduled tasks to do the work! :rolleyes:

By the way; the List Article Plugin is used for updating the article with the changes you make in the article template. I wont trigger the calculation.
 
Now I have studied the Wiki and I really don't have a clue about how to update 2 calculations :( I figure it's not that difficult - but right now it is for me...
 
Well, the real problem is that the form article plugin produces a static snapshot, and writes that in to an article. That's the difference between using a {fabrik ...} content plugin, and the form article plugin.

Using the {fabrik view=details ...} content plugin in an article is "live". It actually builds and renders a Fabrik form from the database data, when the article id displayed. So it renders elements like calc's. etc etc.

Using the 'article' form submission plugin to create an article, you are just writing static HTML in to an article. If the data for that form changes in the database, it will only change in the article if you re-save the form (and hence re-run the article plugin, and regenerate that static HTML from the new data)

Obviously the latter, the form plugin, produces articles which load quicker, and places much less load on the server (rendering a Fabrik form is a fairly heavy weight thing to do), but is "static". Using the content plugin produces "live" forms, but is extra load.

-- hugh
 
Okay - thank you. But I need the indiviual articles, so I can use a module (Roksprocket) to present them. Actually when I use the update_col list plugin the data changes in the articles without resaving them...

But you are telling me, that it's not possible to run a scheduled task that updates my two calculated elements so they will show up correctly in the article? :(
 
Sure you can, it's the question if you could avoid it with a different setup (do you know there's a fabrik list and form module and that you can use the Fabrik content plugin strings in modules, too?)
 
Yep! I know it. And I have tried both with the modules and the list div layout. But Roksprocket has so many layout features, that I want to use. It's like the icing on the great Fabrik cake. Here's an example made for an old artist: http://eggertart.com/galleri.

So you say, that I CAN update with a scheduled task? :rolleyes:
 
Hi Hugh. The prices are in DKK, so it's around ?600. Maybe I can ask him for a discount. But it's localized in Denmark ;)

If you want to try for yourselv, that I'm right about the update_col, I can point to a test site, where I tried it out.

By the way; the url you put in your respons... Is there anyway to make {fabrik_viewurl} return a SEF url?

And do I have to give up on the recalculations?
 
I really thought Denmark has the ?;)

Back to recalculation:
create a php script in ...plugins\fabrik_cron\php\scripts, example
Code:
<?php
defined('_JEXEC') or die('no access');
// get articles
$db = JFactory::getDbo();
$query = $db->getQuery(true);
 
$query
    ->select(array('id','featured','created_by'))
    ->from('#__content')
    ->where('catid = 8');//depends on your set up
 
// Assign the query to the db
$db->setQuery($query);
 
// Load the results as an array of objects.
$rows = $db->loadObjectList();
 
foreach ($rows as $row)
{
$featured_old = $row->featured;
$featured_new = 1; //your calcultion
if ($featured_old != $featured_new)
{
    $query = $db->getQuery(true);
 
    $query
          -> update('zita1_content')
          -> set('featured ='.$featured_new)
          -> where('id = '. (int)$row->id);
   
    $db->setQuery($query);
 
echo $query->dump(); //only for debug
 
    // Run the query
    //$db->execute();
}
exit; //only for debug if running manually and dumping the query
}
 
?>
Add a Fabrik scheduled task, plugin php, select this script.
 
Wow! Thanks a lot Troester. I will try it at once. I'm simply a 'copy/paster'. But I think I know where to put what. The only ting I'm not sure about is 'zital-content'. This script updates the articles? And if... does it help, if the posts aren't reculated. Maybe I'm asking a little stupid :oops:

PS. We danes are not that smart. Said no to the Euro almost only because we want to keep our precious 'krone'. A bit nationalistic o_O
 
'zital-content'
Yup, this is my DB prefix; must be update('#__content') (same as in the select query), Joomla will then insert the correct prefix.

The script will update the Joomla content table directly (check first if you see the correct queries before enableing $db-> execute).
Better backup your #__content table before doing any tests.

If you want to use php plugins (or calc elements) you should know a bit php. You don't need the IF, you can also update every record.

You must still add your calculations ("The fields 'Published' and 'Featured' are referring to calculated elements based on which usergroup the author of a post belongs to.") here again. Maybe you have to select some more information.
How are you calculating this published/featured stuff at the moment?

A bit nationalistic o_O
Hi, hi, I'm from Switzerland where ? and EU are the worst thing ever (for some people).
 
Hi Hugh. The prices are in DKK, so it's around ?600. Maybe I can ask him for a discount. But it's localized in Denmark ;)

Yeah, I'd need about a 90% discount, LOL! Shame, I do really like it.

If you want to try for yourselv, that I'm right about the update_col, I can point to a test site, where I tried it out.

I'd like to see it, yes. I stepped through the code on my test site, and just odn't see anywhere, anyhow that running update_col would trigger a form article plugin re-run.



Hmmm, I thought we did run that through JRoute, I'll check ...

-- hugh
 
No, for some reason we don't ... I suspect because the chunk of code that sets those placeholders up got copied from the email plugin, where the placeholders have to work from outside the domain, and iirc JRoute::_() doesn't do anything if there's a host part on the URL.

You could try this ... edit plugins/fabrik_form/article/article.php, around line 574 you find this:

Code:
        $editURL = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $package . '&amp;view=form&amp;formid=' . $formModel->get('id') . '&amp;rowid='
            . $input->get('rowid', '', 'string');
        $viewURL = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $package . '&amp;view=details&amp;formid=' . $formModel->get('id') . '&amp;rowid='
            . $input->get('rowid', '', 'string');

Try changing it to this:

Code:
        $editURL = COM_FABRIK_LIVESITE . JRoute::_('index.php?option=com_' . $package . '&amp;view=form&amp;formid=' . $formModel->get('id') . '&amp;rowid='
            . $input->get('rowid', '', 'string'));
        $viewURL = COM_FABRIK_LIVESITE . JRoute::_('index.php?option=com_' . $package . '&amp;view=details&amp;formid=' . $formModel->get('id') . '&amp;rowid='
            . $input->get('rowid', '', 'string'));

Although that prolly won't work 'cos of the &amp's ... so you could try changing those to just &.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top