61
BradM
Need coding help for Glossary hack
  • 2003/12/22 19:45

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Hi all,

I've been hacking the Glossary/Glossaire module. As it stands right now, I've added an extra row in the table for 'related terms'. When an entry is displayed, these related terms are automatically hyperlinked (as a search term).

However, what I'd like to do is this: rather than add related terms for each entry, I want to automatically link up words within a definition if they already exist in the database. So if my database has 100 terms in it, and 6 of these words are found in the definition the person is currently viewing, each of the 6 will be hyperlinked.

Here's the code I have for my 'related terms' hack ($glo_related are the related terms stored in the db, separated by commas):
$related_terms preg_split('/,/'$glo_related, -1PREG_SPLIT_NO_EMPTY);
       
$zz=count($related_terms);
    for(
$z=0;$z<$zz;$z++){
        
$replacements[$z] = "<a href='".XOOPS_URL."/modules/glossaire/glossaire-rech.php?terme=".$related_terms[$z]."&type=1'>".$related_terms[$z]."</a>";
           
$glo_definition str_replace($related_terms[$z], $replacements[$z], $glo_definition);
    }


Any ideas on how this can be modified to do what I want it to? The terms are listed in the 'nom' row in the db.

Thanks for any assistance!


Brad



62
BradM
Re: Req: random quote in replace of banners?
  • 2003/12/17 19:18

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


... and if you want to keep banners, just do the following:

Take the code out of the else statement, and put it on its own in the same area.

Change the last line to this:
$xoopsTpl->assign('xoops_randomquote', "$texto $autor2");

And then within your theme.html file, put <{$xoops_randomquote}> wherever you want the quote to appear.


Brad



63
BradM
Re: Req: random quote in replace of banners?
  • 2003/12/17 17:10

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Yep! Now that I've had some sleep my post might make sense!

The following hack will allow you to display the output of the random quote module (found at ModsCentral) in the banner area of your site (but I'm sure it can be used to show it wherever you like)... basically it takes the random quote out of a block. It's actually more of a core hack than theme hack I guess.

Since I don't use banners at my site, I've used that area to build the quote, but I'm sure it can be hacked to show both.

In header.php you'll find this code, starting around line 79:
// show banner?
if ($xoopsConfig['banners'] == 1) {
    
$xoopsTpl->assign('xoops_banner'xoops_getbanner());
} else {
    
$xoopsTpl->assign('xoops_banner''&nbsp;');
}

Since I have banners off, I modified the else condition as follows:
} else {
    
$block = array();
        
$result $xoopsDB->query("SELECT count(*) FROM ".$xoopsDB->prefix("citas"));
    list(
$total_rows) = $xoopsDB->fetchRow($result);
        
$x rand(1,$total_rows);
        
$result $xoopsDB->query("SELECT texto, autor FROM ".$xoopsDB->prefix("citas")." WHERE id=".$x);
        list(
$texto$autor)= $xoopsDB->fetchRow($result);
    if (
$autor) { $autor2 " -- ".$autor; }
    else { 
$autor2 ""; }
    
$xoopsTpl->assign('xoops_banner'"$texto $autor2");
}

The above will then spit out the random quote, with formatting based on td#headerbanner in your theme's css file. It will look something like this:

Have no fear of perfection; you'll never reach it. -- Salvador Dali

if ($autor) { $autor2 " -- ".$autor; }
else { 
$autor2 ""; }

You might be wondering why I have included the above. I use the quote module not only for quotes, but also for small bits of information (for example, the date that a particular event occured). When one of these is displayed, there really isn't an author (autor) associated with it. Therefore I don't want the -- to be displayed after the quote/texto information.

Also, if you want to change the formatting of the quote or author, the easiest way to do this is modify $xoopsTpl->assign('xoops_banner', "$texto $autor2");, for example:

$xoopsTpl->assign('xoops_banner', "<i>$texto</i><BR>$autor2");


I'm pretty new to php, so there might be a better way to do this, but the above seems to work!


Brad



64
BradM
Re: Req: random quote in replace of banners?
  • 2003/12/17 9:22

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


NM, I managed to figure it out. :)




65
BradM
Req: random quote in replace of banners?
  • 2003/12/17 6:56

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Hi,

I don't use banners on my site, so I'd like to throw a random quote up there instead (using the Random Quotes module -- the random quote usually appears in a block). I tried simply adding <{$random_quote_show}> in theme.html, however that produced nothing.

Any ideas or suggestions?


Brad



66
BradM
Modifying a v1.3 module to work with v2.0+ Xoops
  • 2003/12/15 4:44

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Hi all,

I'm currently working on trying to incorporate a v1.3 module to work with the latest version of Xoops.

So far it's actually working not too bad, but there are some output formatting issues I have to figure out. Are there any general things that definitely need to change code-wise that I need to worry about, or any suggestions from those who have successfully converted an old module?

BTW it's the "Storyline" module -- it seems as though the author's website is no longer functioning.


Brad



67
BradM
Amazon mod
  • 2003/12/14 6:49

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Further to a discussion athttps://xoops.org/modules/newbb/viewtopic.php?viewmode=flat&order=ASC&topic_id=9777&forum=20

Can any experienced XOOPS coders tackle this one? I'm not too sure how hard this would be, but it certainly would result in a popular module.

Any sort of breach of ethics involved with this sort of script?


Brad



68
BradM
Custom menu which acts like the Xoops menu
  • 2003/12/13 6:39

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Hi,

I can't seem to find a custom menu builder which creates a menu much like the way XOOPS builds its menus.

For "mymenu", you can only add a link to the main module page. However, when you visit the page, the sub-links do not appear under the main link. If I were to add all the sub-links individually, they'd always be visible, which clutters up the page.

Any ideas or hacks available? I looked at the code in module.php, but was at a loss as to how it could be incorporated into mymenu.


Thanks,
Brad



69
BradM
Re: Glossary Module with bb-code or html-code
  • 2003/12/11 6:33

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


Glad to hear that there will be a new version out in the (near) future. I've been trying to learn php code, and I've been hacking this mod in the process.

If possible, along with the 'associated link', any chance of adding an 'associated image' as well? I hacked mine so that I can use the link for an image instead, but it would be handy to have both options.


Brad



70
BradM
Re: What's the Difference
  • 2003/12/9 8:00

  • BradM

  • Just popping in

  • Posts: 78

  • Since: 2003/8/14


It still shows whatever section you designate as the top page, but the blocks might change depending on what you have given the guest access to.

Check under the groups area in the system admin.


Brad




TopTop
« 1 ... 4 5 6 (7) 8 »



Login

Who's Online

136 user(s) are online (94 user(s) are browsing Support Forums)


Members: 0


Guests: 136


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits