Important Notice: Effective immediately, all support will be handled through Discord. Read more about the changes coming to Anodyne's services.

[MOD] Link Authors in Post to Character Bios

A place to show off (and others to download) completed MODs. Note: support for MODs is handled by third parties, not Anodyne Productions.

jordanjay29 Sat Dec 29, 2012 5:40 pm

[MOD] Link Authors in Post to Character Bios

So I'm getting back into simming, and there's one aspect of forum simms that I adore. The ability to click someone's name on their post, or a link in their signature, and get to their character bio somehow. That functionality doesn't appear in Nova, but I'd sure like it to. Since Nova doesn't have signatures, it'll have to be linked to the author line in the post.

What I mean is to turn this line on a post view page:
Posted on Fri Jan 1st, 1970 @ 12:00am by Captain My Character Name

into this:
Posted on Fri Jan 1st, 1970 @ 12:00am by Captain My Character Name

After spending an afternoon trying to understand Nova's code, I finally figured out a solution. It's not the most elegant, as I'm sure I'm violating some kind of design rule, but this is the simplest and most powerful solution.

This function should work on both Novas 1 and 2(.1), but I have only tested on Nova 2.1. Proceed at your own risk.

Now we're going to get into the code. As for any mod, you'll need an FTP application and access to the Nova files on your server.

[Begin technical speak, you can skip this if you want.]

The function we need lives in /nova/modules/core/models/nova_characters_model.php for Nova 2, and /application/models/base/characters_model_base.php for Nova 1:
Code: Select all
   public function get_authors($character = '', $rank = TRUE)
   {
      $characters = explode(',', $character);
      $characters_final = array();
      
      foreach ($characters as $key)
      {
         $name = $this->get_character_name($key, TRUE);
         
         if ($name !== false)
         {
            $characters_final[] = $name;
         }
      }
      
      if (count($characters_final) > 0)
      {
         $character_string = implode(' & ', $characters_final);
      
         return $character_string;
      }
      
      return false;
   }

The actual modification is just one simple line added to this function. If you want to see it yourself, find this:
Code: Select all
$characters_final[] = $name;

And before it, the line will be this:
Code: Select all
$name = anchor('personnel/character/' . $key,$name);


However, to avoid making edits to the Model file itself, we're going to put our code in /application/models/characters_model.php. This file is in identical locations in both Novas 1 and 2. Putting it in the Application directory ensures that the function is safe from being overwritten between patches, but minor or major updates which touch the file may require this mod to be reapplied.

[If you skipped reading, resume here.]

Open up the /application/models/characters_model.php file.

Find the final brace at the end of the file:
Code: Select all
}

Insert this code before the above line:
Code: Select all
   public function get_authors($character = '', $rank = TRUE)
   {
      $characters = explode(',', $character);
      $characters_final = array();
      
      foreach ($characters as $key)
      {
         $name = $this->get_character_name($key, TRUE);
         
         if ($name !== false)
         {
            $name = anchor('personnel/character/' . $key,$name);
            $characters_final[] = $name;
         }
      }
      
      if (count($characters_final) > 0)
      {
         $character_string = implode(' & ', $characters_final);
      
         return $character_string;
      }
      
      return false;
   }

The above code must be placed before the final brace at the end of the file. If you put it inside any other brace, you will break your code. Make sure you only paste the code at the end of the file, before the final brace.

And the result is this: http://arizona.devira.info/nova2/index. ... viewpost/2

Edit: Found a less-destructive way to do this. Should survive patches, too. Should also work on Nova 1 as well.
User avatar

Posts: 100


Stormwolfe Wed Jan 02, 2013 4:14 pm

Re: [MOD] Link Authors in Post to Character Bios

This looks awesome and would be so handy! I can't count the number of times I've been reading a post and thinking of a reply but had to stop to go look at a character's bio to make sure I had some fact or other straight!

I'll give it a shot on my Dev site because I'm the Nova Village Idiot!

Thanks for the Mod,
User avatar

Posts: 467



Return to Nova MODs

Who is online

Users browsing this forum: No registered users and 1 guest

cron