• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 4.x Series
    • Bug
    • Documentation on how we can enable autolinking on custom content?

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: Documentation on how we can enable autolinking on custom content?

    • Issue Tools
      • View Changes
    1. issueid=6401 October 30, 2023 4:05 AM
      mazzly mazzly is offline
      Junior Member
      Documentation on how we can enable autolinking on custom content?

      We're currently developing a "timeline" add-on for our forum to make a catalog of events that have happened. These events will all have a title and summary, similar to how a thread has a title and message.

      We would want to enable auto-linking for this content, as it will be quite tightly linked/coupled with the wiki content, e.g. the event "Person X dies in Y battle" will autolink as applicable to the character page as well as the battle page


      Is there some documentation on this, or could you provide us with some pointers/code for how we could/should enable this type of feature for our "custom content"?

      Cheers
      //Jonathan
    Issue Details
    Issue Number 6401
    Issue Type Bug
    Project VaultWiki 4.x Series
    Category Plugin System
    Status Fixed
    Priority 3 - Loss of Functionality
    Affected Version 4.1.7
    Fixed Version 4.1.8
    Milestone (none)
    Software DependencyXenForo 2.x
    License TypePaid
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. October 30, 2023 9:22 AM
      pegasus pegasus is offline
      VaultWiki Team
      If your add-on's content is not stored in forums or in wiki areas, you will need to extend src/addons/vw/vw/_core/model/autolink/xf2.php in order for the content to render autolinks. (see comments in src/addons/vw/vw/_hard/core.php resolve_class_name if you have never extended VaultWiki's core classes before)

      In the detect_by_item method, you use the current parser to detect what content is being parsed. If the content is from your add-on, you should return either:
      • a string like 'myaddon', if the content has autolinks enabled (this allows tweaking for each content if you wish, depending on whatever rules you want to set)
      • false, if that content has autolinks disabled

      If the content is not from your add-on, you should return the parent method.

      In the more_checkboxes method, you should add your 'myaddon' string to the $boxes return value. You can then enable autolinking in your content-type overall in the same VaultWiki setting "Enable auto-links to wiki content"

      The way this works is:
      1. The parser looks at the current content being parsed and using detect_by_item to see what autolink rule that content follows (the returned string).
      2. The parser then checks whether that autolink rule is enabled/disabled, by comparing it to the ticked checkboxes.
      3. If all goes well, the autolinker should start finding strings in your content and linking to the appropriate wiki content.
      Reply Reply  
    2. October 30, 2023 12:05 PM
      mazzly mazzly is offline
      Junior Member
      Okay so I've tried to extend, but the `my/class/path` and class naming is a bit unclear and I probably missed some detail there, and I couldn't get it working (no errors tho, silently fails?)... Here is what I currently have:

      `src/addons/MaZ/Calendar/Listener.php` (setup and verified it is triggering):
      Code:
      <?php
      
      namespace MaZ\Calendar;
      
      class Listener
      {
          public static function vw_load_model($classname, $dependency, array &$extend) {
              if ($classname === 'Autolink') {
                  $extend[] = 'Autolink'; // Here surely is one problem...
              }
          }
      }
      Then my class at `src/addons/MaZ/Calendar/vault/plugins/model/autolink/vw.php`:
      Code:
      <?php
      
      class vw_Autolink_Model_Plugin extends vw_AutoLink_Model_Proxy
      {
          public function detect_by_item($parser, $item)
          {
              $rules = $parser->model->rules;
              if ($rules->getContext() == 'maz_calendar') {
                  return 'wiki';  // Lazy way for now, worked when modifying VW source class
              }
              return parent::detect_by_item($parser, $item);
          }
      }
      I'm guessing the `my/class/path` that I couldn't understand is what is messing it up
      Reply Reply  
    3. November 1, 2023 10:12 AM
      pegasus pegasus is offline
      VaultWiki Team
      Ah I see the confusion in the documentation comments. I don't think the text was updated since 4.0.x, and the path is different for XenForo 2. Your class should be located at src/addons/vw/vw/_effects/model/autolink/vw.php. Since this folder is inside the VaultWiki add-on, I recommend adding your add-on's name to the class-path, e.g. ../model/maz/calendar/autolink/vw.php with
      Code:
      $extend[] = 'Maz/Calendar/Autolink';
      If you bundle your add-on please remember to include the src/addons/vw/vw/_effects/[$type]/maz/calendar directories.

      I have updated the comments in the next release to include the default plugin directories for each forum software. The directory is also customizable in src/addons/vw/vw/config.php using VW_PLUGIN_PATH.
      Reply Reply  
    4. November 2, 2023 2:16 AM
      mazzly mazzly is offline
      Junior Member
      Oh, so the class can't be in the folder of our own addon?

      Will see if/how we can bundle that file with the XF2 addon system so that it is placed in the correct place...
      Reply Reply  
    5. November 15, 2023 11:21 AM
      mazzly mazzly is offline
      Junior Member
      Any update on how to fix that loading problem?
      Reply Reply  
    6. November 17, 2023 9:17 AM
      pegasus pegasus is offline
      VaultWiki Team
      I am reading that PHP8 may not like if the argument names don't match exactly, which could mean we need to update some of the example callback signatures.

      In your method definition, please try replacing $extend with $extends, as the underlying code uses the second spelling.
      Reply Reply  
    7. November 21, 2023 9:16 AM
      mazzly mazzly is offline
      Junior Member
      That seems to have done the trick
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 10:16 PM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2025 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
    Copyright © 2008 - 2024 VaultWiki Team, Cracked Egg Studios, LLC.