281
hsalazar
Re: Module Categorization
  • 2003/10/17 6:22

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


sunsnapper:

In fact this will indeed be useful. There's in the horizon a thing called the module registry, where we'll keep track of every module we can find and its features, and certainly having a nice, uncluttered organization will ease things for every xoopser around. Thanks for this draft and for the time it required to do it.

Cheers.



282
hsalazar
Re: little help?
  • 2003/10/16 19:33

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


Hunter:

There's nothing wrong with your site, for the moment. The notices you see are normal for a new installation of XOOPS. Now you need to begin configuring your system.

I'd recommend you to log in and begin playing with the options available. Once you log in, you'll have a single button in the admin section, but that is a powerful button; the system module. Play with its options and you'll soon be doing sites like this...

As head of the documentation team, I'm preparing drafts for the tables of content for several documents we'll begin preparing both for newbies and for regular users. there's a lot happening for the moment behind the curtain, but quite soon the road ahead will be much clearer.

Cheers.



283
hsalazar
Re: Instructions on how to hack a block [Warning: looong post]
  • 2003/10/8 15:19

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1





284
hsalazar
Instructions on how to hack a block [Warning: looong post]
  • 2003/10/8 5:53

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


All:

For those avid xoopsers in search for a natural high, here's a slightly modified version of a post I made in Dr. Clone's site, this time in English for those who either don't speak Cervantes' language or don't visit Dr. Clone's site. The post was an answer to this query (please excuse my very free translation):
Quote:

Hi, everyone:
I know the answer to this has to be easy but I don't have a clue about PHP.
Those of you who use the phenomenal WF-Section will have seen that the blocks showing articles display the title and the date. I'd like to also show the author, just as in the index.php page of WF-Section.
Does anybody know how to do this...?


So, this is the (edited) answer... Let's say that it's not E-A-S-Y as in A-B-C, but neither is this too complicated (me and my big mouth). So let's take advantage of this opportunity to create this micro-tutorial we could call... ta-daaaa! "Instructions on how to hack a block". Ok? Well, then, grab yourself half a ton of patience and try to follow this logic.

(1) Let's begin assuming you've installed WF-Section verion 1.0.1. If you open xoops_version.php, you'll read in lines 68-74:

$modversion['blocks'][6]['file'] = "wfs_new.php";
$modversion['blocks'][6]['name'] = _MI_WFS_BNAME5;
$modversion['blocks'][6]['description'] = "Shows recent articles";
$modversion['blocks'][6]['show_func'] = "b_wfs_new_show";
$modversion['blocks'][6]['edit_func'] = "b_wfs_new_edit";
$modversion['blocks'][6]['options'] = "published|10|25";
$modversion['blocks'][6]['template'] = 'wfs_block_new.html';


(2) What does it tell us? It says that the content displayed through the template called wfs_block_new.html:

<ul>
  <{foreach 
item=wfs from=$block.new}>
    <
li><a href="<{$xoops_url}>/modules/wfsection/article.php?articleid=<{$wfs.id}>"><{$wfs.title}></a> (<{$wfs.new}>)</li>
  <{/foreach}>
</
ul>


is defined functionally in the file wfs_new.php, and that the function involved in this definition, the one in charge of retrieving the most recent articles, is the function called b_wfs_new_show.

(3) Armed with this fearsome knowledge, let's take a look at the said function (lines 29-56 of blocks/wfs_new.php):

function b_wfs_new_show($options) {
    global 
$xoopsDB;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$sql "SELECT articleid, title, published, expired, counter, groupid FROM ".$xoopsDB->prefix("wfs_article")." WHERE published < ".time()." AND published > 0 AND (expired = 0 OR expired > ".time().") AND noshowart = 0 AND offline = 0 ORDER BY ".$options[0]." DESC";
    
$result $xoopsDB->query($sql,$options[1],0);
    while ( 
$myrow $xoopsDB->fetchArray($result) ) {
        
    if(
checkAccess($myrow["groupid"])) {    
        
$wfs = array();
        
$title $myts->makeTboxData4Show($myrow["title"]);
        if ( !
XOOPS_USE_MULTIBYTES ) {
            if (
strlen($myrow['title']) >= $options[2]) {
                
$title $myts->makeTboxData4Show(substr($myrow['title'],0,($options[2] -1)))."...";
            }
        }
        
$wfs['title'] = $title;
        
$wfs['id'] = $myrow['articleid'];
        if ( 
$options[0] == "published" ) {
            
$wfs['new'] = formatTimestamp($myrow['published'],"s");
        } elseif ( 
$options[0] == "counter" ) {
            
$wfs['new'] = $myrow['counter'];
        }
        
$block['new'][] = $wfs;
    }
    }
    return 
$block;
}


(4) As you can probably read in this code, we're retrieving an article's Id, its title, its publication date, its expiration date, its counter and the id of the group with read privileges over the item. No author here. So? Well, do we have any clue about the article's author in the table xoops_wfs_article? If we cheat a little and take a look at its structure, we'll soon find the table includes the user Id of the article's author (uid). This should serve our evil purpose well, hehe. <-- This is supposed to be a diabolical laugh...

(5) Ok. To retrieve the user's name, first we need the database query to retrieve also the field uid. In other words, we need the query to say:

$sql "SELECT articleid, uid, title, published, expired, counter, groupid FROM ".$xoopsDB->prefix("wfs_article")." WHERE published < ".time()." AND published > 0 AND (expired = 0 OR expired > ".time().") AND noshowart = 0 AND offline = 0 ORDER BY ".$options[0]." DESC";


(6) What next? Now we need to assign to a variable not the user Id, but the user's name. In order to do this, we'll execute a little "surgery" from another of Catzwolf's modules, WF-FAQ, and with the swiftness of experienced thiefs, we'll steal a very useful function called getLinkedUnameFromId. This is that function:

function getLinkedUnameFromId($userid)
     {
        
$userid intval($userid);
              if (
$userid 0) {
                
$member_handler =& xoops_gethandler('member');
                  
$user =& $member_handler->getUser($userid);
                      if (
is_object($user)) {
                          
$ts =& MyTextSanitizer::getInstance();
                          
$linkeduser "<a href='".XOOPS_URL."/userinfo.php?uid=".$userid."'>".$ts->htmlSpecialChars($user->getVar('uname')) ."</a>";
                          return 
$linkeduser;
                      }
            }
              return 
$GLOBALS['xoopsConfig']['anonymous'];
      }


(7) I suggest you paste this snippet into the file include/functions.php. Now, for the module to be able to access this function, you need to include in blocks/wfs_new.php, just after the first include_once, the following line:

include_once XOOPS_ROOT_PATH '/modules/wfsection/include/functions.php';


Now the module will know what to do when you use the function, which, as you can deduce from its syntax, is called with the user Id as parameter. What does the function return when called? The user's name, but not in plain old text, but with a hyperlink to the user's profile. Neat!

(8) So let's return to the file blocks/wfs_new.php. Just after the line $wfs['title'] = $title; let's add another line:

$wfs['author'] = getLinkedUnameFromId($myrow['uid']);


Now you'll see a sequence containing the following lines...

$wfs['title'] = $title;
        
$wfs['author'] = getLinkedUnameFromId($myrow['uid']);
        
$wfs['id'] = $myrow['articleid'];


(9) Logic says we're done. The function kicks all variables within the array $wfs, so in the template, where up to this point we were using <{$wfs.id}>, <{$wfs.title}> and <{$wfs.new}>, we can add now <{$wfs.author}>. And your template could say something like:

<ul>
  <{foreach 
item=wfs from=$block.new}>
    <
li><a href="<{$xoops_url}>/modules/wfsection/article.php?articleid=<{$wfs.id}>"><{$wfs.title}></a>, by <{$wfs.author}> (<{$wfs.new}>)</li>
  <{/foreach}>
</
ul>


(10) Initially I posted this sequence out of pure logic, with the utmost lack of good taste that's one of my personal trademarks. Of course there were bugs. Gentle readers made me aware of this, so I humbly ate crow, followed my own advice and hacked the block. Ahem. Had to do a little repair, ahem, a tiny repair, but eventually it worked, so now I can say this hack... works!

Dear xoopsers: if you have the curiosity and the means to follow these instructions, you'll not only be able to hack the block we've been talking about: you'll also learn a more or less general procedure to enjoy playing with XOOPS. And of course, there should be swifter ways, more elegant ways to accomplish the same result. If you know about one, please post it here so we can all benefit and the lesson will grow.

Cheers and best regards.



285
hsalazar
Re: Pop up window
  • 2003/10/8 3:55

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


gruessle:

You can find the code to display a popup window here:

Popup dans XOOPS V2

It's in French but easy to follow. It does imply the creation and reading of a cookie, and you can easily change the duration of this cookie (the default is one day), so the popup doesn't annoy the user.

Cheers.



286
hsalazar
Re: Left block does not disappear when empty.
  • 2003/10/7 6:03

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


gruessle:

This is not a fix, since the persistence of the left block has nothing wrong: it's just the way the theme is done. Assume here we're talking about the default theme; then you'll be able to apply this logic to other themes.

If you open the file theme.html in the theme Default, you'll notice that the TD showing the right column is in the inside of a conditional declaration:

<{if $xoops_showrblock == 1}>

      <
td id="rightcolumn">
        <!-- 
Start right blocks loop -->
        <{foreach 
item=block from=$xoops_rblocks}>
          <{include 
file="default/theme_blockright.html"}>
        <{/foreach}>
        <!-- 
End right blocks loop -->
      </
td>

      <{/if}>

This tells us that this particular TD will show if and only if the variable $xoops_showrblock has a value of 1.

If you look at the TD holding the left column:

<td id="leftcolumn">
        <!-- 
Start left blocks loop -->
        <{foreach 
item=block from=$xoops_lblocks}>
          <{include 
file="default/theme_blockleft.html"}>
        <{/foreach}>
        <!-- 
End left blocks loop -->

      </
td>


... you'll see there's no condition, so the TD appears even if it contains nothing.

How can we change this behavior? We need to enclose this TD in its own conditional, something like:

<{if $xoops_lblocks ""}>
      <
td id="leftcolumn">
        <!-- 
Start left blocks loop -->
        <{foreach 
item=block from=$xoops_lblocks}>
          <{include 
file="default/theme_blockleft.html"}>
        <{/foreach}>
        <!-- 
End left blocks loop -->

      </
td>
      <{/if}>

What we're saying here is: if the array $xoops_lblocks has some content, display the TD.

This should work, at least from the perspective of logic. If it doesn't please tell us in this same thread, in order to further explore the issue.

Cheers.



287
hsalazar
Re: Some pointers on how to build a theme
  • 2003/10/4 5:02

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


Beduc:

If you take a look at the top left corner of this page, you'll see, in the browser banner, a legend stating "XOOPS Official Site - Forum - Microsoft Internet Explorer" or something like this. The first part is the site name, the second is the present module name.

Where is this code in the template (theme.html)? Right where the TITLE tag is. It says:

<title><{$xoops_sitename}> - <{$xoops_pagetitle}></title>

So, there you have the variables you need, already defined. What you need to do is to enclose the first one in a link to your home. This is the way it's solved in Punto flotante:

<td id="breadcrumb" colspan="2">
    <
table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
        <
tr>
            <
td width="10">
            </
td>
            <
td>
                <
div class="breadText">
                    <
a href="<{$xoops_url}>"><{$xoops_sitename}></a> > <{$xoops_pagetitle}>
                </
div>
            </
td>
            <
td width="5">
            </
td>
        </
tr>
    </
table>
</
td>


You can use other styles, DIVs instead of tables or whatever HTML solution you want, but you need to define the path as:

<a href="<{$xoops_url}>"><{$xoops_sitename}></a> > <{$xoops_pagetitle}>

Perhaps you want to go further than just the home and the module name... What about the article name if you're in the news module? To do this you have to edit the file modules/news/article.php. Before the final two includes in the file (around line 116), add the following:

$xoopsTpl->assign('xoops_pagetitle', htmlentities($xoopsModule->name() . ' > ' . $article->title()));

This line will assign to the Smarty variable $xoops_pagetitle (remember it?) a long string that includes the module name, the character '>' and the name of the article. This is the way it's solved in Punto flotante.

Want to go even further? What about including the link in the module name? In this case, what you need to add to article.php es 2 lines instead of one. Add:

$linktomodule = "<a href=\"<{$xoops_url}>/modules/news/index.php\">".htmlentities($xoopsModule->name()."</a>";
$xoopsTpl->assign('xoops_pagetitle', $linktomodule . ' > ' . $article->title()));


This will assign to variable $linktomodule the link to the start page of news and then create a long string that includes this link and the article name, and assign that long variable to the same Smarty variable as above.

Hope this helps.

Cheers



288
hsalazar
Re: Newbb Forums question
  • 2003/10/1 22:48

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


mgcube:

I'm not sure I understand what you ask, but I've posted in one of your sites a thread where you can see the postings in the same page. The only thing I can think of is that perhaps you're talking about the way the posts are displayed when you set the mode to threaded... If that's the case, all you have to do is to select a flat view.

Cheers.



289
hsalazar
Re: Can't login to admin page
  • 2003/10/1 1:40

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


The_Rob:

Since there were some serious issues with version 2.0.4, my suggestion would be to take the site down (if it's new, you don't have a large number of things to backup) and install a 2.0.5RC version, which has many problems solved.

If you do this and still have problems, please report them here and I will gladly try to help you.

Cheers.



290
hsalazar
Re: Removing the intermediate flash screen
  • 2003/10/1 1:32

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


I believe this is not about changing the look & feel of the redirect page, but about getting rid of it. That's at least my gross interpretation, and I do think there's much to discuss about better ways of giving the user feedback.

Let's say, for instance, that you get the feedback message in a DIV and make it visible in the target page. This way you'd never lose the XOOPS interface and still would have your informational messages.

Obviously, the idea would be that if what you do succeeds, you go to the target page and see there a success message, while if you fail (for instance, if you don't have the rights to access some part of the site), you never leave the page, but see the failure message.

Is this the idea, or am I wandering lost in another direction?

Cheers.




TopTop
« 1 ... 26 27 28 (29) 30 31 32 ... 34 »



Login

Who's Online

200 user(s) are online (107 user(s) are browsing Support Forums)


Members: 0


Guests: 200


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