Zan Posted March 4, 2009 Share Posted March 4, 2009 Hi guys, I should provide a bit of back story in this case to make sense of what I want to do. I making the site http://www.couchwarriors.org/ and the news and blogs part of the site are simply pulling forum posts from our simplemachines forum through a very easy to use SSI. The only problem we have with using this is that the SSI can only be set to have a character limit on where it cuts off and says '...' to keep the post length down. I'd like for my forum users to be able to choose what display and what doesn't, and the simplest way I can think of to do this, is to have a function find a string variable (something redundant, perhaps '<s></s>'), count up to that string and assign character limit with that total count. I apologise if this sounds easy, I don't really have much of a coding background and most of my PHP experience consists mostly of fooling around with aforementioned SSIs. Any constructive criticism on the site is more than welcome as well. Link to comment https://forums.phpfreaks.com/topic/147972-counting-a-string-up-to-a-certain-variable/ Share on other sites More sharing options...
rhodesa Posted March 4, 2009 Share Posted March 4, 2009 I like when sites allow me to provide my own "tickler". So there is a small textarea when I can post up to ### number of characters, then the big textarea for my post. If no tickler is provided, then they just take the first ## number of characters from the post Link to comment https://forums.phpfreaks.com/topic/147972-counting-a-string-up-to-a-certain-variable/#findComment-776646 Share on other sites More sharing options...
Zan Posted March 4, 2009 Author Share Posted March 4, 2009 I like when sites allow me to provide my own "tickler". So there is a small textarea when I can post up to ### number of characters, then the big textarea for my post. If no tickler is provided, then they just take the first ## number of characters from the post I have experimented with blogging packages like wordpress that do this well, but we decided not to go with it, as most of our users skip the main site and use the forum, so the idea was to pull interested people to look there. We actually tried to do forum integration with Wordpress and a couple of larger CMS packages, but it got messy really fast. Link to comment https://forums.phpfreaks.com/topic/147972-counting-a-string-up-to-a-certain-variable/#findComment-776662 Share on other sites More sharing options...
rhodesa Posted March 4, 2009 Share Posted March 4, 2009 Joomla does this well if I remember right. They have a button that adds a "break" into the WYSIWYG editor. Long story short, if you want to keep it this way, you will have to add some sort of signifier (like you describe), but you will probably have to start using a server side language (like PHP) to parse for that signifier Link to comment https://forums.phpfreaks.com/topic/147972-counting-a-string-up-to-a-certain-variable/#findComment-776678 Share on other sites More sharing options...
Zan Posted March 4, 2009 Author Share Posted March 4, 2009 Joomla does this well if I remember right. They have a button that adds a "break" into the WYSIWYG editor. Long story short, if you want to keep it this way, you will have to add some sort of signifier (like you describe), but you will probably have to start using a server side language (like PHP) to parse for that signifier That is my understanding, as I described initially. I don't mind dabbling a bit in the php side of things, this is just the first thing I've come across that I haven't been able to google. Link to comment https://forums.phpfreaks.com/topic/147972-counting-a-string-up-to-a-certain-variable/#findComment-776716 Share on other sites More sharing options...
rhodesa Posted March 5, 2009 Share Posted March 5, 2009 well, once that flag is in there, you can just parse it with: if($i = strstr($long,'<s></s>')){ $short = substr($long,0,$i); }else{ $short = "No teaser found"; } Link to comment https://forums.phpfreaks.com/topic/147972-counting-a-string-up-to-a-certain-variable/#findComment-776883 Share on other sites More sharing options...
Zan Posted March 5, 2009 Author Share Posted March 5, 2009 Thank you very much for this. Link to comment https://forums.phpfreaks.com/topic/147972-counting-a-string-up-to-a-certain-variable/#findComment-777566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.