Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom replacer for specific database plugin
#1
Hi all,

I'm far from a PHP guru, especially when it comes to regular expressions.

I've been staring at the code from dynpages, RePlacer and mikeh's new faq, but i just can't seem to get my custom plugin to fetch code properly.

Essentially, I need a custom replace function that won't interfere with other string replacers. It needs to identify a function and possible arguments. The arguments may have spaces inside quotes. It's very similar to dynpages, but I need it for my own plugin that will be very specific for database queries.

I need this:
Code:
{# MyFunction variable1 "variable 2" #}

Where {# should be any unique identifier separate from any other plugins available, and where variables are infinite (or at least zero to four).

Again, this is extremely similar to dynpages, but I just can't wrap my head around regular expression among other stuff. I feel like a smarter coder could just cut-n-paste an answer, but I've already spent too much time on this.

Thanks!
Reply
#2
benrusso Wrote:I've been staring at the code from dynpages, RePlacer and mikeh's new faq, but i just can't seem to get my custom plugin to fetch code properly.

Essentially, I need a custom replace function that won't interfere with other string replacers. It needs to identify a function and possible arguments. The arguments may have spaces inside quotes. It's very similar to dynpages, but I need it for my own plugin that will be very specific for database queries.

I need this:
Code:
{# MyFunction variable1 "variable 2" #}

Where {# should be any unique identifier separate from any other plugins available, and where variables are infinite (or at least zero to four).

If you want to use parameters by position as indicated by your example, look at the source code of the DynPages plugin, if you want parameters by name (param1=value1 param2=value2), look at the source code of I18N Search or I18N Gallery. Change the limiters, if needed.

But why do you not want to use the quite standard method for GetSimple of wrapping your parameters with (% pluginname ... %) where plugin name is a (quite) unique name for the plugin?
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#3
Quote:But why do you not want to use the quite standard method for GetSimple of wrapping your parameters with (% pluginname ... %) where plugin name is a (quite) unique name for the plugin?

That's a very good question. And that's to you stating the obvious, I figured it all out. I feel silly now...

Thanks!
Reply




Users browsing this thread: 1 Guest(s)