Topic: Sections and Displaying each on a new line
mark_psi
avatar
Freshman
Freshman
Posts: 3

Posted:
12.Dec 2003 - 02:59

I am trying to use the sections module for an "Online documentation Feature" So Far, I have everything set but the main options are so close, they appear as one option, for instance:

Code

Here you can find the following sections:


Document Menu 1 Document Menu 2


I would like it to show as

Code

Here you can find the following sections:


Document Window 1
Document Window 2


I looked through the code if /modules/Sections/index.php and found several functions that may work. I tried several options, but haven't seemed to be able to put a "
" in anywhere to make the difference. I am new to PHP, so any help would be appreciated.

Mark
nate_02631
avatar
Professional
Professional
Posts: 3055

Posted:
12.Dec 2003 - 05:08

I'd probably recommend a bit of a PHP primer before doing too many mods, but the function you want is listsections()... Maybe it could go something like this:

Code

function listsections()
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();

    include ('header.php');

    if (!pnSecAuthAction(0, 'Sections::Section', '::', ACCESS_OVERVIEW)) {
        echo _SECTIONSNOAUTH;
        include 'footer.php';
        return;
    }

    $column = &$pntable['sections_column'];
    $result = $dbconn->Execute("SELECT $column[secid], $column[secname], $column[image]
                              FROM $pntable[sections] ORDER BY $column[secname]"
);

    $sitename = pnConfigGetVar('sitename');

    OpenTable();
    echo "<center><font class=\"pn-title\">"._SECWELCOME." ".pnVarPrepForDisplay($sitename).".</font><br /><br />"
        ."<font class=\"pn-normal\">"._YOUCANFIND."</font></center><br /><br />";
    while(list($secid, $secname, $image) = $result->fields) {

        $result->MoveNext();
        if (pnSecAuthAction(0, 'Sections::Section', "$secname::$secid", ACCESS_READ)) {
            echo "<a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=$GLOBALS[ModName]&amp;file=index&amp;req=listarticles&amp;secid=$secid\">";
            if ( ($image == "transparent.gif") or ($image == "") or ($image== "none") )  {
              echo $secname;
            } else {
              echo "<img src=\"images/".strtolower($GLOBALS['ModName'])."/$image\" border=\"0\" Alt=\"$secname\">";
            }
            echo "</a><br>";

        }
    }
    $result->Close();

    CloseTable();
    include ('footer.php');
}

Notice that it does a check for a section image, so if you have one specified it will display that instead of the section name...

--
Get PhotoGallery, PayPalCart, Dynamenu, Enhanced Blocks & other mods

Cape Cod Travel Info...
mark_psi
avatar
Freshman
Freshman
Posts: 3

Posted:
12.Dec 2003 - 18:36

I tried what you suggested buut either I am placing the
in the wrong place or something is wrong. here is the full listing of the code:

Code

function listsections()
{
    list($dbconn) = pnDBGetConn();
    $pntable = pnDBGetTables();

    include ('header.php');

    if (!pnSecAuthAction(0, 'Sections::Section', '::', ACCESS_OVERVIEW)) {
        echo _SECTIONSNOAUTH;
        include 'footer.php';
        return;
    }

    $column = &$pntable['sections_column'];
    $result = $dbconn->Execute("SELECT $column[secid], $column[secname], $column[image]
                              FROM $pntable[sections] ORDER BY $column[secname]"
);

    $sitename = pnConfigGetVar('sitename');

    OpenTable();
    echo "<center><font class=\"pn-title\">"._SECWELCOME." ".pnVarPrepForDisplay($sitename).".</font><br /><br />"
    //  added PLEASENOTE1 line to display warning that Adobe Acrobat is required to view documentation
        ."<font class=\"pn-normal\">"._PLEASENOTE1."</font><br /><br /><br>"
    //added link to adobe acrobat reader  
        ."<a href=\"http://www.adobe.com/products/acrobat/readstep2.html\" TARGET=\"_NEW\"><IMG SRC=\"http://www.oursite.com/support/images/sections/adobe_reader.bmp\" ALT=\"Download Adobe Acrobat Reader\"></a><br /><br />"  
        ."<font class=\"pn-normal\"><b>"._YOUCANFIND."</b></font></CENTER><br /><br />"
        ."<table border=\"0\" align=\"center\"><tr>";
    $count = 0;
    while(list($secid, $secname, $image) = $result->fields) {

        $result->MoveNext();
        if (pnSecAuthAction(0, 'Sections::Section', "$secname::$secid", ACCESS_READ)) {
            if ($count == 2) {
                echo "</tr><tr>";
                $count = 0;
            }
                     echo "<td><a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=$GLOBALS[ModName]&amp;file=index&amp;req=listarticles&amp;secid=$secid\">";
            if ( ($image == "transparent.gif") or ($image == "") or ($image== "none") )  {
                echo $secname;
                // the <br> below makes no difference
                echo "<br>";
                 }
                 else {
              echo "<img src=\"images/".strtolower($GLOBALS['ModName'])."/$image\" border=\"0\" Alt=\"$secname\">";
              // attempting br here to drop listing on each display
              echo "<br>";
              }
              // the <br> below makes no difference                
            echo "</a><br></td>";
            $count++;    
        }
        // a br here drops the entire listing down
    }
    $result->Close();
    echo "</tr></table>";
    CloseTable();
    include ('footer.php');
}


I have made a few changes to it already to display a link for the Adobe Acrobat Reader download.

Thanks for the help!
nate_02631
avatar
Professional
Professional
Posts: 3055

Posted:
12.Dec 2003 - 19:20

I can't help you with that code... Use what I posted above and add your changes to that. It doesn't matter where you place the
- as long as it's in an echo statement it won't cause an error. Check the error message for the line it gives you and check the syntax of your code and correct it. (Missing ";" at the end of an echo statement perhaps?)

--
Get PhotoGallery, PayPalCart, Dynamenu, Enhanced Blocks & other mods

Cape Cod Travel Info...
mark_psi
avatar
Freshman
Freshman
Posts: 3

Posted:
12.Dec 2003 - 21:39

The page never quit working, it was just that the
commands never affected the listing correctly. I resolved the problem by adding a WIDTH attribute to the
line as listed below:

Code

echo "<td WIDTH=\"5%\"><a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=$GLOBALS[ModName]&amp;file=index&amp;req=listarticles&amp;secid=$secid\">";


Thanks for a pointer in the right direction.
nate_02631
avatar
Professional
Professional
Posts: 3055

Posted:
12.Dec 2003 - 22:11

My solution nuked the tables altogether, which would be the way to go; but if you're happy, I'm happy ;)

--
Get PhotoGallery, PayPalCart, Dynamenu, Enhanced Blocks & other mods

Cape Cod Travel Info...