I have made some significant hacks to the Friends Electric theme for a community group website i have put together (will be launched this week)

http://sandon-point.org.au/drupal

i have created some flexinode blocks based on the php snipper available here http://drupal.org/node/4587

    $nlimit = 10;
    $type = "story";
    $result = db_query_range(db_prefix_tables("SELECT n.created, n.title, n.nid, n.changed
    FROM {node} n
    WHERE n.type = '$type'
    ORDER BY n.changed
    DESC "), 0, $nlimit);
    while ($node = db_fetch_object($result)) {
    $items[] = l($node->title,"node/".$node->nid);
    }
    if (isset($items) && is_array($items) && count($items) > 0)
    {
        echo "<ul>";
        foreach ($items as $item)
        {
             echo "<li>" . $item . "</li>";
        }
        echo "</ul>";
    }

Given the css for Friends Electric, the blocks created have bullets outside of the left margin (the unordered list). I want to change the css to look like the navigation block (see http://www.sandon-point.org.au/drupal). Anyone know the most effective wat to achieve this?

There is a repsonse to someone else's query about this, but it is not clear http://drupal.org/node/4587#comment-53844

Any comments would be appreciated.

thanks
c.

Comments

nasi’s picture

Try changing <li> to <li class="leaf">.

If that doesn't work, enclose the whole <ul> block in a <div class="menu"> block.

If you look at the markup you are using for your navigation block and replicate it for this block, you should have the same styles applied to both blocks.

avolve’s picture

thankyou for the help - The css is correct, the issue is i do not know how to replicate the navigation block. So i tried to hack the php snippet in the block - obviously it doesn't work:

First i tried changing li to leaf class:

    $nlimit = 5;
    $type = "story";
    $result = db_query_range(db_prefix_tables("SELECT n.created, n.title, n.nid, n.changed
    FROM {node} n
    WHERE n.type = '$type'
    ORDER BY n.changed
    DESC "), 0, $nlimit);
    while ($node = db_fetch_object($result)) {
    $items[] = l($node->title,"node/".$node->nid);
    }

    if (isset($items) && is_array($items) && count($items) > 0)
    {
        echo "<ul>";
        foreach ($items as $item)
        {
             echo "<li class="leaf">" . $item . "</li>";
        }
        echo "</ul>";
    }

and i got this error:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in ...site/includes/common.inc(1813) : eval()'d code on line 18

So I tried to enclose the whole ul in a div with menu class

    $nlimit = 5;
    $type = "story";
    $result = db_query_range(db_prefix_tables("SELECT n.created, n.title, n.nid, n.changed
    FROM {node} n
    WHERE n.type = '$type'
    ORDER BY n.changed
    DESC "), 0, $nlimit);
    while ($node = db_fetch_object($result)) {
    $items[] = l($node->title,"node/".$node->nid);
    }

<div class="menu">

    if (isset($items) && is_array($items) && count($items) > 0)
    {
        echo "<ul>";
        foreach ($items as $item)
        {
             echo "<li>" . $item . "</li>";
        }
        echo "</ul>";
    }

</div>

yet come up with an error

Parse error: syntax error, unexpected '<' in ..site/includes/common.inc(1813) : eval()'d code on line 13

I assume i need to have some sort of php call (echo?) function? I am pretty stuck on this

Thanks
c.

avolve designs | ethical by design

djpappas’s picture

I'm no PHP expert but I believe your first effort was very close to the mark. Your use of double quotes caused the issue. Try escaping the embeded quotes. This page has a fuller explanation:
http://us2.php.net/types.string

I think you want to use /" instead of " around the class name.

avolve’s picture

Thanks.

This is what i had thought, do did not have the time to continue to go around in circles, what was actually needed was single quotes/apostrophes.

Here is the code posted below for anyone else who may expereince the same thing...

    $nlimit = 5;
    $type = "flexinode-3";
    $result = db_query_range(db_prefix_tables("SELECT n.created, n.title, n.nid, n.changed
    FROM {node} n
    WHERE n.type = '$type'
    ORDER BY n.changed
    DESC "), 0, $nlimit);
    while ($node = db_fetch_object($result)) {
    $items[] = l($node->title,"node/".$node->nid);
    }
    if (isset($items) && is_array($items) && count($items) > 0)
    {
        echo "<ul>";
        foreach ($items as $item)
        {
             echo "<li class='leaf'>" . $item . "</li>";
        }
        echo "</ul>";
    }

avolve designs | ethical by design

nasi’s picture

Your use of single quotes will parse successfully as php, but it won't create correct (x)html as attributes are meant to be enclosed in double quotes.

The solution, is either to switch your use of single and double quotes:

echo '<li class="leaf">';

or to escape the double quotes with backslash:

echo "<li class=\"leaf\">";

As an aside, I've always used the print () command instead of echo. I don't know if there is any technical reason for one to be better than the other or not.

avolve’s picture

I tried both of these - the second does not work (another parse error).

I have changed all those used to the firest suggestion, thanks.

I have left them as echo (at least for now)...

avolve designs | ethical by design