SimplePortal

Customization => Custom Coding => Topic started by: Tiribulus on April 04, 2009, 10:48:59 PM

Title: An off the wall question?
Post by: Tiribulus on April 04, 2009, 10:48:59 PM
I didn't know where else to ask this and it's more just a general question. I noticed a lot times when somebody posts an edit for a user to make, or even in the package parser at the SMF site, they will post a bunch of code, a whole section, when the difference is like one word.

For instance, in another thread here somebody asked about the article mod and Ya??z... told him to replace:
Code: [Select]
            'articles' => array(
               'label' => $txt['sp-adminColumnArticles'],
               'file' => 'SPortalAdmin2.php',
               'function' => 'SPortalAdmin_Articles',
               'subsections' => array(
                  'list' => array($txt['sp-adminArticleListName']),
                  'add' => array($txt['sp-adminArticleAddName']),
               ),
            ),

with:
Code: [Select]
            'articoli' => array(
               'label' => $txt['sp-adminColumnArticles'],
               'file' => 'SPortalAdmin2.php',
               'function' => 'SPortalAdmin_Articles',
               'subsections' => array(
                  'list' => array($txt['sp-adminArticleListName']),
                  'add' => array($txt['sp-adminArticleAddName']),
               ),
            ),

The difference, near as I can tell is between 'articles'  and  ''articoli' , that one piece.

Why not just tell them to change that one word? I've done it this way when applicable when editing for mod installs and it works fine. This is no way a complaint or critique, but pure curiosity. I am entirely unqualified to have an intelligent opinion, but can't help wondering
Thanks.

Title: Re: An off the wall question?
Post by: willerby on April 05, 2009, 06:17:33 PM
I'm no expert either but I suspect if you just replace 'articles' with 'articoli' within the parser it will find more than one instance of the single word.

By finding a larger block of code (automatically with a search or manually) you can be sure you have the right instance. It always looks odd but seems to be the norm?

Title: Re: An off the wall question?
Post by: Nathaniel on April 05, 2009, 07:05:24 PM
Willerby is correct that large ammounts of code are searched for, so that the correct occurance of the word 'articles' is changed. Although the package manager only changes the first occurance of the search term meaning that if 'articles' appeared before that case and you only searched for that term then it wouldn't replace the case you want it to, and could cause errors.

Anyway, there isn't really a reason why they have to search for that much code. Although it should make it easier for the user to identify, as they can just search for a small part of it then use the whole search term to make sure they have the correct occurance. The fact that they included the 'subsections' area actually means that the search term may not exactly exist if a mod for SP added pages to the 'Articles' admin area.

Sorry if that explaination was a bit long. ;)
Title: Re: An off the wall question?
Post by: Tiribulus on April 05, 2009, 11:44:09 PM
That was pretty much along the lines of what I figured when I thought about it more. In short it safeguards against somebody accidentally changing the wrong piece. On the other hand, there have been times that I wind up searching for smaller pieces in the text editor because a mod somewhere along the way has already altered it there and you have to extrapolate whether what you're looking at is the where the original was or not. I wasn't referring to SP in particular with the question BTW, it was just something I noticed. It does make sense to post the larger section though.
Thanks
SimplePortal 2.3.8 © 2008-2024, SimplePortal