Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Themes
Author Message
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1775

PostPosted: Fri Oct 24, 2008 2:56 pm Reply with quote

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 Crying or Very sad


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
 
View user's profile Send private message
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri Oct 24, 2008 6:17 pm Reply with quote

This should help: http://us3.php.net/manual/en/function.strip-tags.php
RavensScripts
 
View user's profile Send private message
neralex







PostPosted: Mon May 04, 2009 7:26 pm Reply with quote

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


Last edited by neralex on Tue May 05, 2009 8:08 pm; edited 1 time in total 
nuken
RavenNuke(tm) Development Team



Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina

PostPosted: Mon May 04, 2009 7:40 pm Reply with quote

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! 
View user's profile Send private message Send e-mail Visit poster's website
Raven







PostPosted: Mon May 04, 2009 10:23 pm Reply with quote

I may be missing something but I'll take that chance Wink

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.
 
Raven







PostPosted: Mon May 04, 2009 10:25 pm Reply with quote

BTW, the best way to achieve the even height 2 column news is to use CSS along with counting the characters Wink


Last edited by Raven on Tue May 05, 2009 12:12 pm; edited 1 time in total 
nuken







PostPosted: Tue May 05, 2009 11:59 am Reply with quote

I have a max characters plugin for the editor that works. If you want it, I will be glad to give it to you.
 
nuken







PostPosted: Tue May 05, 2009 3:36 pm Reply with quote

It includes a count down and only includes <br /> and <p> html tags in the count.
 
neralex







PostPosted: Tue May 05, 2009 4:18 pm Reply with quote

@ 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
 
Raven







PostPosted: Tue May 05, 2009 4:46 pm Reply with quote

neralex, You're most welcome!

nuken, Please send either a link or via email - Thanks!
 
nuken







PostPosted: Tue May 05, 2009 5:31 pm Reply with quote

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!
 
neralex







PostPosted: Tue May 05, 2009 8:06 pm Reply with quote

thanks, nuken!

i will test the plugin in the next days. I will write the feedback here in this thread.

greetz
 
duck
Involved
Involved



Joined: Jul 03, 2006
Posts: 273

PostPosted: Tue May 05, 2009 9:54 pm Reply with quote

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?
 
View user's profile Send private message
Raven







PostPosted: Tue May 05, 2009 11:38 pm Reply with quote

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
 
duck







PostPosted: Wed May 06, 2009 10:51 am Reply with quote

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 Wink


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.
 
neralex







PostPosted: Thu Dec 02, 2010 7:15 am Reply with quote

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
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Themes

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©