So i should check for the hooks in the renderExample function right? I have
pasted the code in the extension file below. Will that work
Also the reference information should be entered into the page table also? Or
should it just be in the reference and referencelinks table?.
<?php
$wgExtensionFunctions[] = "wfReferenceExtension";
function wfReferenceExtension()
{
global $wgParser;
$wgParser->setHook("ref","renderReference");
}
function renderReference($input)
{
$referenceText = $input;
//to separate id and the refname to display
$reference = explode(" ",$referenceText);
//get the actual display reference
$refDisplay = $reference[0]."]";
//to get teh actual reference Id to insert into the table
$tempId = $reference[1];
$temp = explode("]",$tempId);
$refId = $temp[0];
$wgHooks['ArticleSaveComplete'][] = array
('myAddReferenceFunction',$refId);
$output = "$refDisplay";
return $output;
}
function myAddReferenceFunction($refId)
{
//db functions
}
?>
Thanks
I have created a table called reference links similar
to the imagelinks
table.
When a user enters his reference using an external
link his reference gets
entered into the reference table and in the textarea he can actually see the
<ref>23</ref>, where the 23 is the refId from the reference table. I want to
insert this info in the referencelinks table only when article is finally
saved and not previewed. But when a user hits preview it should show actually
pull up the reference name from the database and show that and similarly for
preview.
Check the hooks ArticleSave and ArticleSaveComplete. Wait for those to
be called before commiting data to the DB.
--
Amruta