vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Plugin Help - str_replace ? (https://vborg.vbsupport.ru/showthread.php?t=170516)

dartho 02-14-2008 09:59 PM

Plugin Help - str_replace ?
 
I'm still a novice, that's why I'm asking here!

I'd like to create a plugin that will do a simple string replace on the "<HTML>" tag on ALL pages.

I want to replace <html ......>

with <html id=blah ......>

I have previously done a search and replace on all templates, but thought a plugin would be nicer - I try not to manually edit any templates.

Any help appreciated - thanks

Eikinskjaldi 02-14-2008 10:02 PM

Templates are called with the fetch_template function, have a look in that. It probably lives in functions.php or bigthree, I don't have vb handy to check.

Boofo 02-14-2008 10:06 PM

Wouldn't that already be parsed at that point?

cheesegrits 02-14-2008 10:25 PM

It'd might easier to do this with a little bit of javascript in the headinclude template (or add it to $headinclude in a plugin like global_start).

Something like this might do it ...

HTML Code:

<script type="text/javascript">
<!--
window.addEvent('domready', function () {
    document.getElementsByTagName('html')[0].setAttribute('id','blah');
});
-->

</script>

-- hugh

dartho 02-15-2008 08:26 AM

No joy with this - i'm thinking old fashioned search and replace may be easiest...

Thanks for the suggestions!

cheesegrits 02-15-2008 02:26 PM

Ooops, my apologies, I've been coding with Mootools for too long, keep forgetting vB doesn't use it! So window.addEvent() doesn't exist.

Don't really need it tho. Just do this somewhere in headinclude:

HTML Code:

<script type="text/javascript">
<!--
document.getElementsByTagName('html')[0].setAttribute('id','blah');
-->

</script>

I just tested it, and it works fine:

HTML Code:

<html id="blah" lang="en" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
NOTE - if you just 'View Source", you won't see the change to the html tag. Show source only shows you the page as it was loaded from the server, it doesn't show you any modifications made to the DOM by any JavaScript. You need to run something like FireBug in FireFox to see the modified DOM structure, and use FireBug to "Inspect" the HTML. Then you'll see the modified DOM.

(DOM is the Document Object Model, the actual structure of your page within the browser)

-- hugh

dartho 02-15-2008 11:08 PM

Will test this out later - thanks. Wonder how Google and the link will see it? I'm testing a theory that google uses ID tags when ranking keywords and thinking this may be yet another SEO helper ...


All times are GMT. The time now is 12:51 PM.

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.01017 seconds
  • Memory Usage 1,722KB
  • 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
  • (3)bbcode_html_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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