Is there anyway to cite a biblio entry in a node (using FCKEditor) like what we do by [bib] tag but print the biblio attributes just where we used [bib] tag not at the end of the page? I mean i want a page like this:

Dear students please see J. carry "title of the biblio", 1999, publisher and write a review for that blah blah blah.

Now I use the link to content plugin for FCKeditor but it shows the title of the biblio pages only. I think it may be because it could not access biblio pages attributes.
I know that it is not a popular feature, however, could you guide me if I can tweak it myself?

Thanks in advance

Comments

rjerome’s picture

Anything is possible...

The best way would be to define a new tag type, maybe [ibib] or something like that. There are basically two functions involved and they're both in the biblio.module file. The biblio_filter function defines the tags and how they are operated on. So near the top of the biblio_filter function, you would have to change it to something like this...

  if ($op == 'list') {
    return array(
    0 => t('Biblio module references &lt;bib&gt; <i>or</i> [bib]'),
    1 => t('Biblio module inline references &lt;ibib&gt; <i>or</i> [ibib]'),
    );
  }

Then a bit further down you would have to make another delta (1) case to match the above new tag (1)

  switch ($delta) {
    // First is the html footnotes filter
    case 0 :
      switch ($op) {
        // This description is shown in the administrative interface, unlike the
        // filter tips which are shown in the content editing interface.
        case 'description' :
          return t('Use &lt;bib&gt;citekey&lt;/bib&gt; or [bib]citebkey[/bib]to insert automatically numbered references.');
          // We don't need the "prepare" operation for this filter, but it's required
          // to at least return the input text as-is.
          //TODO: May need to escape <fn> if we use HTML filter too, but Footnotes could be first
        case 'prepare' :
          return $text;
          // The actual filtering is performed here. The supplied text should be
          // returned, once any necessary substitutions have taken place.
        case 'process' :
          $pattern = array('|\[bib](.*?)\[/bib]|s', '|<bib>(.*?)</bib>|s');
          if (variable_get('biblio_footnotes_integration', 0) && module_exists('footnotes')) { // this is used with footnote module integration to replace the <bib> tags with <fn> tags
            $text = preg_replace_callback($pattern, '_biblio_filter_footnote_callback', $text);
            return $text;
          }
          else {
            $text = preg_replace_callback($pattern, '_biblio_filter_replace_callback', $text);
            //Replace tag <footnotes> with the list of footnotes.
            //If tag is not present, by default add the footnotes at the end.
            //Thanks to acp on drupal.org for this idea. see http://drupal.org/node/87226
            $footer = '';
            $footer = _biblio_filter_replace_callback(NULL, 'output footer');
            if (preg_match('/<bibliography(\/( )?)?>/', $text) > 0) {
              $text = preg_replace('/<bibliography(\/( )?)?>/', $footer, $text, 1);
              return $text;
            }
            else {
              return $text ."\n\n". $footer;
            }
          }
      }
      break;
   case 1 :
      switch ($op) {
        // This description is shown in the administrative interface, unlike the
        // filter tips which are shown in the content editing interface.
        case 'description' :
          return t('Use &lt;ibib&gt;citekey&lt;/ibib&gt; or [ibib]citebkey[/ibib]to insert inline references.');
          // We don't need the "prepare" operation for this filter, but it's required
          // to at least return the input text as-is.
          //TODO: May need to escape <fn> if we use HTML filter too, but Footnotes could be first
        case 'prepare' :
          return $text;
          // The actual filtering is performed here. The supplied text should be
          // returned, once any necessary substitutions have taken place.
        case 'process' :
          $pattern = array('|\[ibib](.*?)\[/ibib]|s', '|<ibib>(.*?)</ibib>|s');
          $text = preg_replace_callback($pattern, '_biblio_inline_filter_replace_callback', $text);
          return $text
      }
      break;

  }

Then add the new function to handle the replacement...

function _biblio_inline_filter_replace_callback($matches) {
    $text =  _biblio_citekey_print($matches[1]) ;
  return $text;
}

That should do it, but I haven't tested this code so it may not be completely bug free.

Ron.

masood_mj’s picture

Thanks a lot.
Biblio module is my favorite module not just because of itself but also because of its writer.

a bug:
; after the last return $text

last step:
enable ibib filter at the input formats

Thanks again

rjerome’s picture

Thanks for the kind words,

So if I understand correctly what I described above (with the debugging and enabling) worked as you desired and we can call this fixed?

Ron.

masood_mj’s picture

Status: Active » Fixed

yes

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

matthiassamwald’s picture

Status: Closed (fixed) » Active

I think the feature requested in this issue is quite handy (I would need it as well). Since the code is already there, why not integrate it into the official version of Biblio? It would be much appreciated!

rjerome’s picture

Status: Active » Fixed

I've added the feature described above to the code.

Ron.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.