Author |
Message |
neralex
Site Admin
![](modules/Forums/images/avatars/201442295664a46e4575d46.jpg)
Joined: Aug 22, 2007
Posts: 1775
|
Posted:
Fri Oct 24, 2008 2:56 pm |
|
Hey!
I have set the news-tables in my theme next to each other. but now is the place for the news-teaser smaller and i try it to set a limit of displayed charakters.
i go to my theme.php search for the function themeindex:
Code:if ("$aid" == "$informant") {
$content = "$thetext$notes\n";
|
and set these two lines under it:
Code:if(strlen($content)>260) $content02=substr($content,0,257)."...";
else $content02=$content;
|
it works all fine but the HTML-Tags was counted, too
how can I set a HTML-Filter to my counter?
i found a lot of threads to this action but not of all working in my themeindex.
http://www.php.net/manual/en/function.strlen.php#84104
greetz |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
Site Admin/Owner
![](modules/Forums/images/avatars/45030c033f18773153cd2.gif)
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Fri Oct 24, 2008 6:17 pm |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon May 04, 2009 7:26 pm |
|
hey raven!
i try it to set a limit of displayed charakters, too.
strip_tags remove all HTML-Tags from my chars. i would like to count all chars and to limit these to a certain number. but all HTML-Tags was counted, too.
if i use strip_tags, then all HTML-Tags are not indicated. The HTML-Tags are to be indicated however and not be considered during counting the chars.
the counter should count the chars without HTML-Tags.
can you help me, please...?
for example:
look on nukescripts or trickedoutnews. the news-modules are display all news in 2 columns.the news blocks with different heights are shown with the different lengths of the texts ($content in storyhome). I would like to indicate the news blocks only the certain number of chars in these, in order to avoid exactly this problem. i use the original news module of RN 2.30.01 with a code change in my theme.
thanks&greets
![Crying or Very sad](modules/Forums/images/smiles/icon_cry.gif) |
Last edited by neralex on Tue May 05, 2009 8:08 pm; edited 1 time in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
nuken
RavenNuke(tm) Development Team
![](modules/Forums/images/avatars/3234de284ee21bd39eecd.jpg)
Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina
|
Posted:
Mon May 04, 2009 7:40 pm |
|
I have been working on that same issue for my next release of Tricked Out News. The direction I am going in is a javascript character counter addon for the nukeWYSIWYG editor. If you overcome the html tag issue, please let me know. I keep hitting a dead end. |
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon May 04, 2009 10:23 pm |
|
I may be missing something but I'll take that chance
Let's say you have a line of formatted text like the following and your limit is 40. Now if you just do a character count of the string you will get 46. Why not just set a temporary variable that is the strip_tags($var_str) version, count the characters in the tempvar, compare that against your limit and respond accordingly? Something like this.
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<?php
$var_str = '<p>This is a <strong>test</strong> string.</p>';
echo 'The value of $var_str is <strong>' . htmlentities($var_str) . '</strong>';
echo '<br />';
echo 'The length of $var_str with html tags is: ' . strlen($var_str);
echo '<br /><br />';
$Tvar_str = strip_tags($var_str);
echo 'The value of $Tvar_str [strip_tags($var_str)] is <strong>' . htmlentities($Tvar_str) . '</strong>';
echo '<br />';
echo 'The length of $Tvar_str [strip_tags($var_str)] without html tags is: ' . strlen($Tvar_str);
?>
</body>
</html>
|
This could be done in PHP or Javascript. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Mon May 04, 2009 10:25 pm |
|
BTW, the best way to achieve the even height 2 column news is to use CSS along with counting the characters ![Wink](modules/Forums/images/smiles/icon_wink.gif) |
Last edited by Raven on Tue May 05, 2009 12:12 pm; edited 1 time in total |
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
nuken
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue May 05, 2009 11:59 am |
|
I have a max characters plugin for the editor that works. If you want it, I will be glad to give it to you. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
nuken
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue May 05, 2009 3:36 pm |
|
It includes a count down and only includes <br /> and <p> html tags in the count. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue May 05, 2009 4:18 pm |
|
@ raven:
1000 thanks from germany. this is the solution. many many thanks!!!
@nuken:
this is a good idea and its welcome. if you want, send me link to the plugin.
greetz |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue May 05, 2009 4:46 pm |
|
neralex, You're most welcome!
nuken, Please send either a link or via email - Thanks! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
nuken
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue May 05, 2009 5:31 pm |
|
Ok. Here is a link for the plugin. Only registered users can see links on this board! Get registered or login!. It has the plugin and edited fckconfig.js file. I added 2 new toolbars named NewsAdmin and NewsUser to replace the PHPNukeAdmin toolbar in the news admin and the NukeUser in Submit News. When you call the Character Counter in the toolbar, it will limit that textarea to whatever the limit set in the plugin .js file is. If the toolbar does not have the Counter added to it, it functions normally. You will probably need to delete cookies and internet files before the renamed toolbars will load, I did. The News/admin/index.php file and the Submit_News/index.php file are the ones to replace the toolbars for the hometext area in.
Edit.
Here is a link to premodded news admin and submit news files.
Only registered users can see links on this board! Get registered or login! |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue May 05, 2009 8:06 pm |
|
thanks, nuken!
i will test the plugin in the next days. I will write the feedback here in this thread.
greetz |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
duck
Involved
![Involved Involved](modules/Forums/images/ranks/4stars.gif)
![](modules/Forums/images/avatars/gallery/blank.gif)
Joined: Jul 03, 2006
Posts: 273
|
Posted:
Tue May 05, 2009 9:54 pm |
|
correct me if I am wrong but I don't think you need to set a temp variable to perform the stripped tag check do you?
Can't you just do this?
Code:if(strlen(strip_tags($content))>260) $content02= htmlentities(substr(strip_tags($content),0,257))."...";
else $content02=$content;
|
mind you you may wish to to do a decode on entities too if data is stored encoded already? |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
Raven
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Tue May 05, 2009 11:38 pm |
|
No, you don't. There are almost always more than one way to code things. But I try to give examples that are easily understood and maintained ![Wink](modules/Forums/images/smiles/icon_wink.gif) |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
duck
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Wed May 06, 2009 10:51 am |
|
Raven wrote: | No, you don't. There are almost always more than one way to code things. But I try to give examples that are easily understood and maintained |
Yeah was making sure cause I wasn't sure if strip_tags is one of those functions that you can't use in that manner as I thought I remember reading once about a function or 2 in php where the function can't be used in this manner cause anything sent it is always by reference so the original value will get manipulated anyway. d***ed if I can remember what those functions were?
I tested this one though and it does work fine. |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
neralex
![](modules/Forums/images/avatars/gallery/blank.gif)
|
Posted:
Thu Dec 02, 2010 7:15 am |
|
nuken wrote: | Ok. Here is a link for the plugin. Only registered users can see links on this board! Get registered or login!. It has the plugin and edited fckconfig.js file. I added 2 new toolbars named NewsAdmin and NewsUser to replace the PHPNukeAdmin toolbar in the news admin and the NukeUser in Submit News. When you call the Character Counter in the toolbar, it will limit that textarea to whatever the limit set in the plugin .js file is. If the toolbar does not have the Counter added to it, it functions normally. You will probably need to delete cookies and internet files before the renamed toolbars will load, I did. The News/admin/index.php file and the Submit_News/index.php file are the ones to replace the toolbars for the hometext area in.
Edit.
Here is a link to premodded news admin and submit news files.
Only registered users can see links on this board! Get registered or login! |
is this plugin not more supported or where i can get it?
Edit & solved: i have found this here in a another thread!
http://www.ravenphpscripts.com/postt19367 |
|
|
|
![](themes/RavenIce/forums/images/spacer.gif) |
|