More PHP foolishness...need help!

Associate
Joined
29 Dec 2004
Posts
2,252
Hallo again chaps, id like your help tweaking the following bit of code:

<?php

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

include_once( $mosConfig_absolute_path."/administrator/components/com_docman/docman.class.php");

global $_DOCMAN;
if(!is_object($_DOCMAN)) {
$_DOCMAN = new dmMainFrame();
}

$_DOCMAN->setType(_DM_TYPE_MODULE);
$_DOCMAN->loadLanguage('modules');

require_once($_DOCMAN->getPath('classes', 'utils'));
require_once($_DOCMAN->getPath('classes', 'file'));
require_once($_DOCMAN->getPath('classes', 'model'));

// get the parameters

$limits = abs($params->def( 'limits', 3 ));
$show_icon = abs($params->def( 'show_icon', 1 ));
$show_category = abs($params->def( 'show_category', 1 ));

$menuid = $_DOCMAN->getMenuId();

$content ="";
$enum = 0;

$rows = DOCMAN_Docs::getDocsByUserAccess(0, 'date', '', $limits);

foreach ($rows as $row)
{
$doc = new DOCMAN_Document($row->id);

$url = sefRelToAbs( "index.php?option=com_docman&amp;task=cat_view&amp;Itemid=$menuid&amp;gid=".$doc->getData('catid')."&amp;orderby=dmdate_published&amp;ascdesc=DESC" );
$content .= "<a class=\"dm_mod_latestdown\" href=\"$url\">";

if ($show_icon)
$content .= "<img src=\"".$doc->getPath('icon', 1, '16x16')."\" alt=\"file icon\" border=\"0\"/> ";

$content=$content."<b>".$doc->getData('dmname')."</b>";

if ($show_category)
$content .= "<br />(".$row->cat_title.")";

$content .= "</a><br />";

$enum++;
}
if (!$count = count($rows))
$content=$content."<br />"._DML_MOD_NODOCUMENTS;
?>

I have been trying to add a couple of <br>'s at the bottom but whatever i put it just comes up at the top? Even if i try <? echo "<br /><br />"; ?> at the bottom of all of it it appears at the top?!

Also - i would like to restrict the amount of charecters to a certain number, say 20, and then have "..." at the end so that if someone has a long download title it will stay on one line and say "Example Download Hel..." rather than "Example Download Hello World" and going onto another line (this script shows latest downloads in a small width column and i want to keep it neat if possible!).

Appreciate any help you can give :)
 
Beansprout said:
That script is throwing output into $content (albeit badly) so presumably you can

Thanks for that. I thought it could have been done in a slightly better way too, not that i would have a clue where to start...anywhoo, i added that line just before the end ?> and its worked a treat. Thanks very much :)

Any ideas about restricting the outputted text to no more than 20 charecters and adding "..." on the end if it is longer than 20?
 
Heres an example of what i would like to do:

Latest Forum Posts

Got problems with the ...
Posted by RichL
Oooh Lyn!
Posted by RichL
Itchy Throats
Posted by richieboy

Notice how the post that has a title longer than 22 characters has "..." on the end rather than displaying the full title? This is what i would like to implement for the code i posted in my first post - but i dont know how to do it? Appreciate any help for implementing it with my code :) , i have tried a few things but none of them work!
 
Thanks, i came up with this:

$shortname = $doc->getData('dmname');

if ( strlen($shortname) > 23 )
$shortname = substr($shortname, 0, 23) . '..';
else
$shortname = $shortname;

And it bloomin works, i cant beleive i managed to put your example in with what i had and make it work - fantastic! Thanks again rob, my site is progressing quite nicely :) . That said...im going to post another question in a second!
 
PHP:
dude.. stop using [quote] for code. (hint.. use [code])

Code:
dude.. stop using [quote.] for code. (hint.. use [code.])

dude.. stop using [quote.] for code. (hint.. use [code.])

If it gets the point across - whats the bloomin difference? Im going to do it...i feel its required....yup, there it goes.... :rolleyes:
 
Back
Top Bottom