vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   php calling for use in pages (https://vborg.vbsupport.ru/showthread.php?t=185068)

Mum 07-12-2008 02:39 AM

php calling for use in pages
 
I am wanting to take the username, and if it has a space in it replace it with an _

I am not up with programming, so am trying to figure it out. I got this far.

<$irc_user = str_replace(' ', '_', $bbuserinfo[username]);>

Am i heading totally down the wrong track? Can i use this straight in the template? I don't know what to search for to help me, i am a complete noob at this.

Thank you for any help in advance.

Ideal Web Tech 07-12-2008 03:49 AM

You cant use php in the templates. You will need to make a plugin for the global_start hook that contains the following code (the plugin could change if you only need it in a specific area, this would make it available globally).
PHP Code:

<?php $irc_user str_replace(' ''_'$vbulletin->userinfo['username']); ?>


Mum 07-12-2008 08:22 AM

Is it a problem to have it available globally? Ie does it slow anything down or affect anything?

I need it available for forumhome template and also a custom template page.

--------------- Added [DATE]1215854750[/DATE] at [TIME]1215854750[/TIME] ---------------

Quote:

Originally Posted by Ideal Web Tech (Post 1573282)
You cant use php in the templates. You will need to make a plugin for the global_start hook that contains the following code

I have searched for a template called global_start... and there isn't one, so can you please point me in the direction of how i can create this hook? Sorry, this is my first time trying to do something like this.

--------------- Added [DATE]1215855674[/DATE] at [TIME]1215855674[/TIME] ---------------

Ok i added a hook sorry i have read up about it) but that doesn't doesn't work, either for people with spaces or without.

Opserty 07-12-2008 09:22 AM

Don't add the opening and closing PHP tags.

AdminCP > Plugins & Products > Add New Plugin

Hook Location: global_start
PHP Code:
PHP Code:

$irc_user str_replace(' ''_'$vbulletin->userinfo['username']); 


Mum 07-12-2008 09:42 AM

Thank you so much :) I hadn't realised that! It works perfectly.

Again, thank you very much :)


All times are GMT. The time now is 11:46 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04928 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete