• Purchasing a license grants permission to use the software and to get Tech Support. A license purchase doesn't grant customization support.

Must read How to find something in the code?

Rodolfo

Chevereto Developer
Chevereto Staff
Joined
Oct 7, 2008
Messages
15,524
Points
237
Location
Chevereto HQ
Website
rodolfoberrios.com
Hey there,

This guide will allow anyone to find anything inside Chevereto code (in any code actually).

I wrote this because when someone ask me where is something I actually do a code search and just return the results of that search. I believe that everybody figures that because I don't know exactly where everything is located in Chevereto, is too big to have a mental map of everything.

I will describe two methods that I use everyday and later I will elaborate on the most important thing: The search string.

Method 1: GitHub search (lazy)
  1. Go to Chevereto-Free at GitHub
  2. On top bar it reads "This repository" and next to it "Search"
  3. Enter the search string that you are looking for and submit the form
  4. Filter search results by language (PHP, JS)
Method 1 doesn't require anything in your end but it only search for code in the free edition and uses GitHub search engine (not that good). But is OK if you are lazy or you don't want to give that much trouble.

Method 2: Actual code search (best)
  1. Get a working copy of your website (or a base release that matches your website)
  2. Get any text editor with search feature
  3. On your text editor, find "Search", put your search string, tweak search parameters (include folders, recursive search if possible)
  4. Submit the form, you should get results shortly.
Method 2 requires a text editor (I use Notepad++ in Windows) and I'm almost sure that you will be able to find several code editors that will perform this code search in any directory you add to this search (you don't need to search each file).

Search string and real examples

The most important thing to keep in mind is to determine a good search string. For example, if you want to search for lets say the "Add image URLs" modal box:

upload_2017-4-28_19-26-8.png

You should figure out that good search strings should be:
  • Add image URLs
  • Add the image URLs here
For "Add image URLs" you will get something like this:
Code:
Search "Add image URLs" (1 hit in 1 file)
  Chevereto\app\themes\Peafowl\snippets\anywhere_upload.php (1 hit)
    Line 306:             <span class="modal-box-title"><?php _se('Add image URLs'); ?></span>
Note that I got an exact match because I searched to match case (lowercase and uppercase are not the same). Look what I get if I don't match case:

Code:
Search "Add image URLs" (3 hits in 1 file)
  Chevereto\app\themes\Peafowl\snippets\anywhere_upload.php (3 hits)
    Line 24:                             '%u' => '<a data-modal="form" data-target="anywhere-upload-paste-url">' . _s('add image URLs') . '</a>',
    Line 28:                             '%u' => '<a data-modal="form" data-target="anywhere-upload-paste-url">' . _s('add image URLs') . '</a>',
    Line 306:             <span class="modal-box-title"><?php _se('Add image URLs'); ?></span>
As you may notice two results are for links and one for the actual text being used in the modal. Always narrow down your search for stuff like match case, .php files, directory where to look for, etc. There are words present in almost every file so the best you narrow down the search, the better results you will get.

Another example, lets say that you want to change where it reads "Followers":

upload_2017-4-28_19-43-6.png

Unfortunately "Followers" is a very common word, so in this case you should include HTML in your search string. Open your browser's console and inspect the "Followers" element. You will get something like this:

upload_2017-4-28_19-44-37.png

So your search should be for this:
Code:
<span data-text="followers-label" data-label-single="Follower" data-label-plural="Followers">Followers</span>
But for that you won't get results. That's very common because this is an HTML section which is generated via PHP, you will need to remove some characters from your initial search string. Key point is to still preserve the "unique" element, in this case that element is data-text="followers-label".

The final search string looks like this:
Code:
<span data-text="followers-label" data-label-single=
And it narrows down to this section in the code:
Code:
<span data-text="followers-label" data-label-single="<?php _ne('Follower', 'Followers', 1); ?>" data-label-plural="<?php _ne('Follower', 'Followers', 2); ?>"><?php _ne('Follower', 'Followers', get_user()['followers']); ?></span>
Note that is impossible to get to this search result by just searching using generated HTML code. Please keep that in mind when performing code search.

Hope this guide helps.

Cheers,
Rodolfo.