Please upgrade here. These earlier versions are no longer being updated and have security issues.

Linking Excerpts to the discussion

This discussion is related to the DiscussionExcerpt2 addon.
rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one"NY ✭✭✭

I started by wanting to replace the "..." at the end of the excerpt with a "more..." button that links to the relevant discussion (exactly as if the user clicked on thee title). Lacking real programming skills I was only able to make the change of adding the button. My changes (marked with ***RB) after line56:

         if (count($words) > $Number_of_words) {
             echo '<div class="DiscussionExcerpt2">' . implode(' ', array_slice($words, 0, $Number_of_words)) ;
             echo ' <img src="plugins/DiscussionExcerpt2/more_button.png"'; /****RB  */
             echo ' >';/****RB room to add link (what's the url???)*/
             echo '</div>';/****RB    */

(1) Can someone suggest the code of how to add the necessary link?
(2) Even with #1 above answered, my solution is somewhat deficient because short posts don't get the button (since nothing is truncated). The ideal solution would be to set the entire excerpt (including the button if there is one) as a link to the discussion. How can this be done?

Comments

  • whu606whu606 I'm not a SuperHero; I just like wearing tights... Moderator

    @x00 replied (in another thread)

    You could do something like

    $DiscussionUrl = $Sender->EventArguments['DiscussionUrl'];
    

    then

    echo '<div class="DiscussionExcerpt2">' . implode(' ', array_slice($words, 0, $Number_of_words)) . Anchor('more...',$DiscussionUrl,'Button').' </div>';
    

    Button is the class, you can add additional classes e.g. Button YourClass

    R_Jhgtonight
  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Thanks X00 (and thanks whu606 for merging the question). I tried this solution and it fully addresses the button question. Alas, as I mentioned, the ideal solution would be to make the entire excerpt linking to the post exactly as the title does. This way the user can click on the excerpt (easier on mobile devices) and it would work whether it the excerpt is truncated (in which case the button appears) or not.

  • Well you have Anchors so just wrap the except text with the anchor

    Don't nest anchors, use two anchors, one for the text an one for the "button"

    grep is your friend.

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    You both give me too much credit and a learning challenge. So I went on the web and figured out what an anchor is. I now think I am up to the challenge;-) Thanks!

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    I am happy to announce that X00's significant help and pointing got me, a non-programmer, to alter the plugin so that:
    1. The excerpt links to the post exactly as the title does. Makes it easier clicking for mobile users.
    2. If the excerpt is truncated, a custom "more..." button is displayed instead of the original ellipses.

    My changes below, right after line 52 and marked with **RB*.

           $Announce = $Discussion->Announce;
               $DiscussionUrl = $Sender->EventArguments['DiscussionUrl'];         /****RB With X00's help*/    
               echo '<div class="DiscussionExcerpt2">';                           /****RB I'm wrapping the excerpt in an anchor that links to the post */
               echo '<a href="vanilla/' ;                                         /****RB The Vanilla url prefix may be different in your forum */
               echo $DiscussionUrl.'"> ';                                         /****RB */
               $words = explode(' ', $FirstComment);
               if ( ($Announce != 1 ) || ( $Announce && $Show_announcements )) {
                              if (count($words) > $Number_of_words) {
                   echo implode(' ', array_slice($words, 0, $Number_of_words));
                   echo '</a>';                                                   /****RB separating excerpt and button anchors*/
                   echo ' <a href="vanilla/';                                     /****RB Again, the Vanilla url prefix may be different in your forum */
                   echo $DiscussionUrl.'"> ';                                     /****RB */
                   $Buttonimage = 'plugins/DiscussionExcerpt2/more_button.png';   /****RB pick your preferred "More..." button/style */
                   echo ' <img src="'.$Buttonimage.'" >';                         /****RB  */
              } else {
                 echo $FirstComment;
             }
             echo ' </a></div>';                                                  /****RB  closing anchor - everything will link to the post*/
    
    hgtonight
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Let that be the first step into the beautifully simple world of writing Vanilla plugins!


  • hgtonighthgtonight ∞ · New Moderator

    Nice! I knew you could do it @rbrahmson‌ :)

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    Thank you all for your encouragement, but in all honesty this exercise only increased my appreciation for you guys, the Illuminati;-)

    If there is one thread that is implicit in my posts it is that I sense that Vanilla, with relatively little work, could expand to audiences who don't know programming at all. In the same manner that so many are able to create PowerPoint presentations without knowing much about what goes behind the scenes. If I am right, Vanilla could really explode into a much wider audience.
    Anyway, before I digress too much -- thank you all!

  • i would learn he basics of html before moving on to more complex sever side code, though.

    grep is your friend.

    peregrine
  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    @rbrahmson said:
    If there is one thread that is implicit in my posts it is that I sense that Vanilla, with relatively little work, could expand to audiences who don't know programming at all.

    The well known forum scripts are created just to be forum scripts. Vanilla is based on a MVC framework called Garden (at least FluxBB and MyBB are following that trend and the next major releases of them will be based on Laravel/Yii as far as I know). The downside of a framework is the overhead that might lead to a lower performance than using a "dedicated" (don't know a better word) forum script. One of the positive aspects is that developers don't have to reinvent the wheel over and over again. If you get used to the helper functions the framework offers you, you can achieve a big impact with very little code.

    But nevertheless, you'll have to code. You'll have to have at least a basic understanding of any programming language and you really should read about the principles of MVC (Model View Controller). Otherwise you might get something to work, but you'll never be able to understand what you are doing and you surely be not able to write more than trivial plugins.


  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    I understand and even went to read about MVC. My point is that with the growing power of computers and their related costs, the overhead of additional layers is becoming a non-issue. With that in mind I dare to suggest that with some extra work another layer could be created on top of what Vanilla offers, one that would allow the larger non-programmer audience to create forums without coding.
    In the short term this may be against the interests of the developers. Long term, I believe, it would grow the community in significant ways and create even larger demand for customization.

    All those with good intentions who encourage me to learn programming are proving my point that right now this is a limited community. How many non-programmers ever went to learn PHP and were able to code to the MVC architecture? Not many I bet. Again, what I see in Vanilla as a potential to break out is the clean user interface and the variety of plugins. The MVC architecture should make it realtively easy for professional programmers to get it to the next level. It's a team effort project, so I don't know if it will ever happen in a community like this.

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    I guess you are looking for a CMS. That kind of software is specialized for being used not by programmers but by content editors. Some of them are made so that you as a user can add as much functionality to your site as possible without coding.
    Ease of extensibility should be no goal for a forum to my opinion. It merely is some kind of a side effect of well organized and structured code base...

    You might be interested in TikiWiki: they have a integrated nearly everything in their software and it is possible (though I did not find it easy) to extend it even more.
    Another CMS that I like is ProcessWire. There has been a basic forum extension some years ago and I think it still is very basic, but I always found it feels some kind of "natural" how you have to extend ProcessWire. By the way: I've read a discussion over there where they state that they do not strive for creating a PW based forum because such specialized software should better be embedded.

    But you can search for a CMS that offers what you need here: http://www.cmsmatrix.org/matrix/cms-matrix?func=search They have a lot of search filters!


  • hgtonighthgtonight ∞ · New Moderator

    @rbrahmson‌ You might be interested in @Shadowdare‌ 's article application proposal found here: http://vanillaforums.org/discussion/24731/articles-blog-app-proposal-looking-for-sponsors

    It is an example of how nice functionality can be integrated with Vanilla. A fully fledged articles application would help a lot, imo. Maybe you can throw $10 at it too ;)

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    Shadowdare
  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    To @R_J: No, not looking for CMS. Just for a clean interface discussion platform with security and relatively easy customization. Encountered Vanilla by chance and found it a good match for the first two and moderately so for the latter.

    To @hgtonight: Thanks for the pointer - while I am not looking for CMS, I do find that project useful and pledged to it.

    hgtonightShadowdare
Sign In or Register to comment.