News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Search before and after

Started by The One, March 19, 2007, 08:29:24 AM

Previous topic - Next topic

The One

I am trying to create a mod using the directions given in the package_sdk.
I am searching both before and after and then doing an add in my xml file however I see that the code I am adding is being added twice instead of once.

This is the code I am using in the XML file
<operation>
<search position="before"><![CDATA[
// Do some logging, unless this is an attachment, avatar, theme option or XML feed.
if (empty($_REQUEST['action']) || !in_array($_REQUEST['action'], array('dlattach', 'jsoption', '.xml')))
{
// Log this user as online.
writeLog();

// Track forum statistics and hits...?
if (!empty($modSettings['hitStats']))
trackStats(array('hits' => '+'));
}
]]></search>
<search position="after"><![CDATA[
// Is the forum in maintenance mode? (doesn't apply to administrators.)
if (!empty($maintenance) && !allowedTo('admin_forum'))
]]></search>
<add><![CDATA[
        // Perform the Windows Domain user check for the visitor
        domain_userCheck();
]]></add>
</operation>

Any idea how this is happening? And how to rectify it?
The problem is choice

The One

*bump*
Do mod writers do a search for both "before" and "after" when they make any changes or is it only either one of them?
The problem is choice

KGIII

(I left your post and removed the one before it - I don't know your answer directly EXCEPT to say that you must be careful of whitespace. No EXTRA spaces at all or the proverbial fecal matter hits the fictional fan.)

My PC Support Forum
Please ask in-thread before PMing
                   SMF Help
                   Visit My Blog

How can we improve the support process?:
http://www.simplemachines.org/community/index.php?topic=163533.0

SMF vs. Godzilla? Who do you think will win?

Dannii

I only ever have seen one search tag used.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

The One

@KGIII: you can delete my the post after that too (with the  ???) as well as this  :)
The problem is choice

The One

The package_sdk readme specifically mentions that it is better to use both before and after so that we get to the exact location we need to add code.
So I was assuming everyone does this most of the time and I was missing something?
The problem is choice

B Patterson

yes, the SDK says it's better to use both, but I had the EXACT same issue as you when I first started developing mods.  Unfortunately it doesn't seem that multiple search items aren't supported.  So you have to search either before or after only.

Joshua Dickerson

You should only need one. If you want to make absolutely sure that it is the correct block, try replace.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Dannii

I don't think replace will make it any more sure. Just make sure it's unique by searching for the text, it should appear only once. Try and include a comment in your search, they're nearly all unique.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

The One

Have done that for now.
BTW it would be great if we could do a search for both before and after so that we get the location right. Not sure how easy it is to do this though.
The problem is choice

Advertisement: