1. Thank you for all the good wishes. I'm headed in for surgery (lumbar fusion) tomorrow, Thursday July 31st, I'll be in hospital for three days, and out of action for a few days after that. See y'all in about a week! Hugh.

Jcomments Latest Comments module URL writing needs to be tweaked

Discussion in 'Plugins' started by mk1200, Nov 17, 2011.

  1. mk1200 Member

    Level: Community
    I posted this over at Joomlatune. Wanted to run it past The Fabrik wizards too.

    I'm using Jcomments and tried the Latest Comments module, but the URL isn't right.

    Bad URL from Latest Comments module, which works if you're on the same page as the original comment:
    Code (text):
    index.php?option=com_fabrik&view=table&tableid=4&calculations=0&resetfilters=0&Itemid=2#comment-3
    Good URL from comment-anchor counter in comments:
    Code (text):
    index.php?option=com_fabrik&c=form&view=form&Itemid=2&fabrik=4&tableid=4&rowid=49#comment-3
    It's controlled by lines 430 - 434 of mod_jcomments.php and I think line 383 where the $link variable is.

    View attachment mod_jcomments.txt
  2. cheesegrits Support Gopher

    Level: Community
    Unfortunately $link is being created by calling one of their helper routines from a file in the main component, not in the mod_jcomments.php.

    How is the actual linkage between Fabrik and JComments happening? Are you using our 'comments' form plugin?

    If so, I'll need to install JComments (I've only ever used our own built in method for the form comments) and attempt to replicate your issue.

    -- hugh
  3. mk1200 Member

    Level: Community
    Thanks Hugh, I've been digging in and saw that it relies on the JCommentsObjectHelper. I am using your comments form plugin.

    I may just hack the module file to get the URL to show up correctly, but if you have a better solution, I'm all ears.

    The Latest Comments module isn't part of the default Jcomments install, so that's probably why no one has seen this issue before.
  4. mk1200 Member

    Level: Community
    I think a plugin in the components/com_jcomments/plugins may be required. My error log is filled since there isn't a com_fabrik_4.plugin.php file. My form ID is 4 and that's what I put in the Latest Comments module source parameter. I imagine if a plugin was created it would be just com_fabrik.plugin.php. Looks like this is where the $link variable would be set from looking at the other plugin files.
  5. mk1200 Member

    Level: Community
    1) The Jcomments component is not happy about the missing plugin.php file. The file name needs to include the form or table # like com_fabrik_4.plugin.php. I tried creating test files, but they didn't alter the way links were displayed in the module. Not sure what the plugin file does.

    2) I hacked the Latest Comments module and it's not pretty, but the links work now. I'm using the 2nd parameter in the module settings "Comment text style Show as linked text" and edited line 430 of mod_jcomments.php.

    Code (text):
    echo '<a class="jcl_comment" href="index.php?option=com_fabrik&amp;c=form&amp;view=form&amp;Itemid=2&amp;fabrik=4&amp;tableid=4&amp;rowid='.$row->object_id.'#comment-'.$row->id.'" title="'.$link_title.'">'.$link_text.'</a>';
    I need to add more variables so it works with other forms.
  6. zottl New Member

    Level: Community
    did you have any success so far?
  7. mk1200 Member

    Level: Community
    Yes, what I have above works for me, but I only have one form. More variables would be needed so it would work across multiple forms.
  8. zottl New Member

    Level: Community
    Yeah, it also works for me with one form. But right now I try to get it working for a second form, with no success so far..

    Have you ever tried to add one more variable? You know how that variable should look like?

    I tried it with a workaround by installing a second instance of mod_jcomments. I just renamned every necessairy file to something like mod_jcomments1.php etc...

    then i just added the second variable to the new mod_jcomments1.php.

    But sadly the copy i created doesnt really work independently (I dont know why) and it still gives me the link to the first form (where I use the original mod_jcomments)..

    regards!
  9. mk1200 Member

    Level: Community
    I'm not much of a programmer, so one of the support crew will have to jump on this one.

    To make this compatible, you need to return the value of the variables for Itemid, fabrik and tableid in line 430:

    Code (text):
    echo '<a class="jcl_comment" href="index.php?option=com_fabrik&amp;c=form&amp;view=form&amp;Itemid=2&amp;fabrik=4&amp;tableid=4&amp;rowid='.$row->object_id.'#comment-'.$row->id.'" title="'.$link_title.'">'.$link_text.'</a>';
    Getting this done is over my head though.
  10. zottl New Member

    Level: Community
    Alright, got a working an easy solution for this one.

    Its very simple:

    1st step is to edit "mod_jcomments.xml". So open that file and go to line number 145. There yoo just add as many options as you wish to the 3 existing ones. In my case it looks like:

    Code (text):
    <option value="0">Show as plain text</option>

    <option value="1">Show as linked text</option>

    <option value="2">Show as plain text with Readmore link</option>
               
    <option value="3">fabrik1</option>
               
    <option value="4">fabrik2</option>
    2nd step is to open "mod_jcomments.php" and go to line number 430. There you just add as many "cases" as you added to your xml file. As I use the "readmore-link" to the comment, my 2 new cases (case 3 and 4) look like:

    PHP:
                        case 0:
                            echo '<span class="jcl_comment">'.$link_text.'</span>';
                            break;
                        case 1:
                            echo '<a class="jcl_comment" href="'.$link.'#comment-'.$row->id.'" title="'.$link_title.'">'.$link_text.'</a>';
                            break;
                        case 2:
                            echo '<span class="jcl_comment">'.$link_text.'</span> ';
                            echo '<a class="jcl_readmore" href="'.$link.'#comment-'.$row->id.'">'.$label4more.'</a>';
                            break;
                        case 3:
                            echo '<span class="jcl_comment">'.$link_text.'</span> ';
                            echo '<a class="jcl_readmore" href="index.php?option=com_fabrik&amp;c=form&amp;view=form&amp;Itemid=&amp;fabrik=5&amp;tableid=5&amp;rowid='.$row->object_id.'#comment-'.$row->id.'">'.$label4more.'</a>';
                            break;
                        case 4:
                            echo '<span class="jcl_comment">'.$link_text.'</span> ';
                            echo '<a class="jcl_readmore" href="index.php?option=com_fabrik&amp;c=form&amp;view=form&amp;Itemid=&amp;fabrik=34&amp;tableid=34&amp;rowid='.$row->object_id.'#comment-'.$row->id.'">'.$label4more.'</a>';
                            break;                                             
                    }
    where 5 (case 3) and 34 (@case4) are my table-ids.

    3rd step is to just copy the mod_jcomments go to its settings and set your desired case for each copy!

    voila!
  11. mk1200 Member

    Level: Community
    Ha, nice work! We're hackers :)

Share This Page