Topic: Setting the image path based on user style

I am trying to figure out how I can add an image for example this works in viewtopic

<img src="img/'.$pun_user['style'].'/buttons/btn_icon_email.png">

but the same image path does not work in any other file for me. I am trying to get it to work on a file that resides in my include/user folder. Can someone please tell me what it is I need to add to make it work.

Thanks
Bingiman

Re: Setting the image path based on user style

<img src="'.$pun_config[o_base_url].'/img/'.$pun_user['style'].'/buttons/btn_icon_email.png">

Re: Setting the image path based on user style

That actualyl doesn't work for me. This is what I am using.

<img style="vertical-align: middle;" src="'.$pun_config[o_base_url].'/img/'.$pun_user['style'].'/blog_icon_dot.gif">

Re: Setting the image path based on user style

echo '<img style="vertical-align: middle;" src="'.$pun_config['o_base_url'].'/img/'.$pun_user['style'].'/blog_icon_dot.gif">';

There are a couple reasons the code you had wouldn't work. This code should work fine, assuming you're inside a block of PHP

Re: Setting the image path based on user style

I am using it inside include/user/blogmenu.php and it doesn't work. Here is the script.

<?php

/*********************************************************************
start output of the left block
*********************************************************************/
require PUN_ROOT.'lang/'.$pun_user['language'].'/blog.php';    

if ($bid > 0 || $cid > 0 || $cat_id > 0 || $pop > 0 || $lat > 0 || $comm > 0)
{
?>
 
<?php
}
?>
    <div class="block">
        <h2 class="block2"><span><?php echo $lang_blog['Blogs menu'] ?></span></h2>
        <div class="box">
            <div class="inbox"><dl>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_dot.gif" alt="" /> <a href="blogs.php"><?php echo $lang_blog['User blogs'] ?></a></dd>


<?php
if (!$pun_user['is_guest'])
{
?>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_dot.gif" alt="" /> <a href="blogs.php?bid=<?php echo $pun_user['id'] ?>"><?php echo $lang_blog['View mine'] ?></a></dd>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_dot.gif" alt="" /> <a href="blogs.php?uid=<?php echo $pun_user['id'] ?>"><?php echo $lang_blog['Create'] ?></a></dd>
<?php
}
if ($pun_user['is_guest']) 
{
$result = $db->query('SELECT cat_id FROM '.$db->prefix.'blog_perms WHERE post_cat=1 AND group_id=3') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    if ($db->num_rows($result))
    {
?>
                        <dd><a href="blogs.php?uid=<?php echo $pun_user['id'] ?>">Create New Blog</a></dd>
<?php
    }
}
?>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_dot.gif" alt="" /> <a href="blogs.php?lat=1"><?php echo $lang_blog['Latest'] ?></a></dd>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_dot.gif" alt="" /> <a href="blogs.php?pop=1"><?php echo $lang_blog['Most viewed'] ?></a></dd>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_dot.gif" alt="" /> <a href="blogs.php?comm=1">Most Commented</a></dd>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_dot.gif" alt="" /> <a href="userlist.php?bloggers"><?php echo $lang_blog['Blogger list'] ?></a></dd>
                    </dl><hr />
                    <dl>
                        <dt><span class="blogcats"><?php echo $lang_blog['Categories'] ?></span></dt>

<?php
$result = $db->query('SELECT c.* FROM '.$db->prefix.'blog_categories AS c LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=c.id AND p.group_id='.$pun_user['g_id'].') WHERE p.read_cat IS NULL OR p.read_cat=1  ORDER BY c.num_blogs DESC') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    while ($cat = $db->fetch_assoc($result))
    {

?>
                        <dd><img style="vertical-align: middle;" src="img/blog_icon_redarrow.gif" alt="" /> <a href="blogs.php?cat_id=<?php echo $cat['id'] ?>"><?php echo pun_htmlspecialchars($cat['categories']) ?> - <?php echo $cat['num_blogs'] ?></a></dd>
<?php
    }
?>
                    </dl><hr />
                    <dl>
                        <dt><span class="bloglatest"><?php echo $lang_blog['Latest'] ?></span></dt>

<?php
    //$result = $db->query('SELECT * FROM '.$db->prefix.'blogs ORDER BY id DESC LIMIT 0 , 10') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT b.* FROM '.$db->prefix.'blogs AS b LEFT JOIN '.$db->prefix.'blog_perms AS p ON (p.cat_id=b.cat_id AND p.group_id='.$pun_user['g_id'].') WHERE p.read_cat IS NULL OR p.read_cat=1  ORDER BY b.id DESC LIMIT 0 , 10') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    while ($cur_blog = $db->fetch_assoc($result))
    {

?>
                                <dd><img style="vertical-align: middle;" src="img/blog_icon_bluearrow.gif" alt="" /> <a href="blogs.php?cid=<?php echo $cur_blog['id'] ?>&c_id=<?php echo $cur_blog['id'] ?>" title="<?php echo $cur_blog['heading'] ?>"><?php echo substr($cur_blog['heading'],0 ,15) ?>...</a></dd>
<?php
    }
?>
                    </dl><hr />
                    <dl>
                        <dt><span class="bloglatest_bloggers"><?php echo $lang_blog['Latest bloggers'] ?></span></dt>
<?php
$result = $db->query('SELECT DISTINCT poster, poster_id FROM '.$db->prefix.'blogs') or error('Unable to fetch blog info', __FILE__, __LINE__, $db->error());
    while ($blogger = $db->fetch_assoc($result))
    {

?>
                            <dd><img style="vertical-align: middle;" src="img/blog_icon_greenarrow.gif" alt="" /> <a href="blogs.php?bid=<?php echo $blogger['poster_id'] ?>"><?php echo pun_htmlspecialchars($blogger['poster']) ?></a></dd>
<?php
    }
?>                    </dl>
 
            </div>
        </div>                        
    </div>

Re: Setting the image path based on user style

I don't see any of that code being used anywhere in the code you just pasted

Re: Setting the image path based on user style

I am just showing you the original code before I tried the above. I did try the code above and it doesn't work. I replaced all the img paths with the one posted here and it doesn't work.

8

Re: Setting the image path based on user style

Why are you bothering. You could just set the images as backgrounds on the dd's in which case you would vary the image path in each stylesheet.

Re: Setting the image path based on user style

ok, thanks Paul. I will go try that now.

Re: Setting the image path based on user style

I tried but nothing seems to line up as far as the images go. sad

Re: Setting the image path based on user style

I used the following and it seemed to work fine:

.icon_dot {
    color: #EDEFF4; 
    background-position: 0% 65%; 
    background-repeat: no-repeat; 
    background-image: url('../../img/Aphrodite/blog_icon_dot.gif'); 
    padding: 0px;
}

12

Re: Setting the image path based on user style

That looks right though I would have thought a background position of "center left" should have done it. Also remember to give the dd some left padding to leave room for the image.

13 (edited by bingiman 2007-07-09 00:00)

Re: Setting the image path based on user style

I actually used 2  . For some reason padding has no effect on it at all. You can see it on http://shednotes.com under the blog menu.

Thanks Paul

14

Re: Setting the image path based on user style

Thats probably just a specificity problem. .pun dd has a specificity of 11 and is set to no padding. .icon-dot has a specificity of 10 so it will be overruled. Try dd.icon-dot {padding-left: 10px} which has a specificity of 11. If that doesn't work then .pun #right dd.icon-dot {padding-left: 10px} which as a specificity of 121.

Re: Setting the image path based on user style

I used the following and it works great!

/* display blog indicators */
dd.icon_dot, 
dd.icon_dot_red,
dd.icon_dot_blue,
dd.icon_dot_green {
    padding-left: 7px
}

Thank you!
Bingiman