|
|
Forum moderator: bigblog |
uCoz Community For Webmasters Custom Solutions Help with substr(S,N1,N2) (In the module Forum/with extracting forum id from URLS) |
Help with substr(S,N1,N2) |
These are my custom HTML buttons for adding forum posts...Since their isn't a code for the forum ID i have to extract it from $REQUEST_URI$ in order to make these buttons work, i know the maximum number i will be limited is to 1000 characters.
"/forum/2-7-1" i need only to extract number "2" but if their will bigger numbers like 10,100...i will the Substr to extract them... Code <?if($CUR_FORUM_NAME$)?> <?if($CUR_THREAD_NAME$)?><a class="b-button small" <?if($USER_LOGGED_IN$)?>href="#post"<?else?>onclick="_uWnd.alert('Необходима авторизация для данного действия. Войдите или зарегистрируйтесь.','',{w:230,h:80,tm:3000});return false;" rel="nofollow" href="javascript://"<?endif?>>Ответить</a><?endif?> <a class="b-button small" <?if($USER_LOGGED_IN$)?>href="http://www.god4life.tk/forum/<?if($PAGE_ID$=="threadpage")?><?substr($REQUEST_URI$,7,-4)?><?else?><?substr($REQUEST_URI$,7,1000)?><?endif?>-0-0-1-1"<?else?>onclick="_uWn d.alert('Необходима авторизация для данного действия. Войдите или зарегистрируйтесь.','',{w:230,h:80,tm:3000});return false;" rel="nofollow" href="javascript://"<?endif?>>Новая тема</a> <a class="b-button small" <?if($USER_LOGGED_IN$)?>href="http://www.god4life.tk/forum/<?if($PAGE_ID$=="threadpage")?><?substr($REQUEST_URI$,7,-4)?><?else?><?substr($REQUEST_URI$,7,1000)?><?endif?>-0-0-1-2"<?else?>onclick="_uWn d.alert('Необходима авторизация для данного действия. Войдите или зарегистрируйтесь.','',{w:230,h:80,tm:3000});return false;" rel="nofollow" href="javascript://"<?endif?>>Новый опрос</a> <?endif?> </div> Added (2014-07-06, 4:06 PM) --------------------------------------------- Please help! If you do not understand what I mean, read this FIRST. Reference - URL: http://www.site.com/forum/2-7-1 - Goal/Point/Idea: My point is to extract the ID of the forum. I would gladly use $URI_ID$, but since it only works on forum but not on threads I have to opt out for another section. Since $REQUEST_URI$ features the url /forum/2-7-1[What ever module you are in the code gives the url,after www.site.com] By using<?substr($REQUEST_URI$,7,1000)?>, I can extract the FORUM ID. But since the number of characters change when it reaches 10,100,1000 and so on. I do not have a proper solution. If their is a seperate code for FORUM ID, the provide it to me otherwise help me out with this Hit that "Thanks" button. :)
In life there's ALWAYS limits but do not plan above them. Post edited by VZ - Sunday, 2014-07-06, 10:18 PM
|
VZ, from what I can remember when I first developed uAnswers that was the only way I managed, if you create an out point for the substring though I think it works. I can't remember exactly what I did, if I find it I'll give you a holla.
Jack of all trades in development, design, strategy.
Working as a Support Engineer. Been here for 13 years and counting. |
| |||
| |||