ahh ok! thanks for the hint - it works now, but all my conditioned styling does not work anymore
i have $ShortDiscussionNameAnchor = '<a href="'.htmlspecialchars(Url('/discussion'. $DiscussionID . '/' .rawurlencode($Discussion->DiscussionID))).'/'.Gdn_Format::Url($Discussion->Name).'"'.$CssClass.'>'.htmlspecialchars($DiscussionNameShort).'</a>';
and later
<?php if ($Discussion->Announce == '1' && ($Session->IsValid() && $Discussion->CountUnreadComments < 1)) {
echo Anchor($ShortDiscussionNameAnchor, $DiscussionUrl, 'TitleRedRead');
}
elseif ...and many more
that basically gives announcements that a user has already read the link color 'red' and font-weight:normal via the class TitleRedRead. the next few elseif's give the discussiontitles either font-weight:bold or not depending on whether there are new posts or not
so since i replaced $DiscussionName with $ShortDiscussionNameAnchor it is not assigning the classes (e.g. TitleRedRead) to the link ..
i'm clueless mybe i have been staring at the screen for too long to get it .. have been on the computer for .. way too long without a break for my mind :-P
since the function is this.
function Anchor($Text, $Destination = '', $CssClass = '', $Attributes = '', $ForceAnchor = FALSE) {
this appears to be strange - are you sure?
echo Anchor($ShortDiscussionNameAnchor, $DiscussionUrl, 'TitleRedRead')
I would think the first parameter is text (e.g. Title).
$DiscussionNameShort = $Discussion->Name;
if (strlen($DiscussionNameShort) > 56 )
$DiscussionNameShort = substr($DiscussionNameShort,0,56) . '...';
echo Anchor($DiscussionNameShort, $DiscussionUrl, 'TitleRedRead');
I'm not quite sure what you are doing.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
for the shortened usernames. i actually ended up adding a title to the shortened username links that outputs the complete username and i was hoping i could do the same with the discussion title, but it doesn't seem to work
now the titles are shortened and the styling is working too, which is great. thanks
i just noticed, that when there is a long discussion title that ends with a special character (in todays case ", then it abbreviates wrong and ends up showing &qu... (from ")
Answers
you have to pull it out of Discussion object and set it first.
$DiscussionId = $Discussion->DiscussionID;
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
ahh ok! thanks for the hint - it works now, but all my conditioned styling does not work anymore
i have
$ShortDiscussionNameAnchor = '<a href="'.htmlspecialchars(Url('/discussion'. $DiscussionID . '/' .rawurlencode($Discussion->DiscussionID))).'/'.Gdn_Format::Url($Discussion->Name).'"'.$CssClass.'>'.htmlspecialchars($DiscussionNameShort).'</a>';
and later
that basically gives announcements that a user has already read the link color 'red' and font-weight:normal via the class TitleRedRead. the next few elseif's give the discussiontitles either font-weight:bold or not depending on whether there are new posts or not
so since i replaced $DiscussionName with $ShortDiscussionNameAnchor it is not assigning the classes (e.g. TitleRedRead) to the link ..
i'm clueless mybe i have been staring at the screen for too long to get it .. have been on the computer for .. way too long without a break for my mind :-P
I'm not quite sure what you are doing.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
ah ok this makes much more sense to me now. thanks for explaining! i just assumed i had to redefine the link similar to
$newanchor = '<a href="'.htmlspecialchars(Url('/profile/'.$UserID . '/' .rawurlencode($Last->Name))).'"'.$CssClass.'>'.htmlspecialchars($short).'</a>';
for the shortened usernames. i actually ended up adding a title to the shortened username links that outputs the complete username and i was hoping i could do the same with the discussion title, but it doesn't seem to work
now the titles are shortened and the styling is working too, which is great. thanks
@peregrine
i just noticed, that when there is a long discussion title that ends with a special character (in todays case
"
, then it abbreviates wrong and ends up showing&qu...
(from"
)is there a way to fix this?
you could strip the special characters period that would be the easiest.
can you show an image example?
or you would need to keep track of opening and closing quotes.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
not sure what you mean by 'strip the special characters period'
here is an example image. notice the
&q...
instead of"
at the end of the abbreviated discussion titleshorten it up if it finds an ampersand towards the last 5 characters of string.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
good idea, will implement that! thanks : )
you're spreading quite a bit of knowledge, thanks for that