hints
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| hints [2016/03/27 17:11] – admin | hints [2026/03/21 10:11] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Hints ====== | ====== Hints ====== | ||
| - | ===== PHP Includes | + | Practical tips and best practices (some are reminders of common knowledge, but worth repeating). |
| - | Some people include | + | ===== Includes in PHP files ===== |
| + | |||
| + | I've encountered constructions | ||
| include(' | include(' | ||
| Line 11: | Line 13: | ||
| virtual('/ | virtual('/ | ||
| - | or | + | Having even a few of these—especially 10 per template—significantly impacts performance. |
| - | readfile(' | + | **Why this matters:** |
| + | PHP processes includes before the page is sent to the browser. Remote includes cause page delivery delays. If the remote server slows down, your site slows down too. | ||
| - | moreover they use it may times per page. | + | Even on the same server, virtual('/ |
| - | You should NOT use it. | ||
| - | **Why:** | + | **The right approach:** |
| - | PHP creates page BEFORE user gets it. So if you have something like include(' | + | Always use local includes |
| - | There 2 downsides of this approach: | + | include('/ |
| - | * PHP create a regular connection to that host requesting a page. If you have 10 such includes - 1 request | + | If you need to include a file from another domain on the same server, use a different path. If it's on another server, ask your admin to set up a cron job to sync the file locally, then include |
| - | * If for some reason PHP won't be able to connect | + | |
| + | **Similar issue:** | ||
| - | **What to do:** | + | readfile(' |
| - | Use only local includes. | ||
| - | Ie virtual('/ | ||
| - | if file is located at another server - ask admin to setup rsync or copy file using crontab and so on. | + | **Passing parameters |
| - | + | ||
| - | **Including local script | + | Most banner rotators use JavaScript includes, but some require PHP includes. Avoid remote includes |
| - | Let's say you have include like | ||
| - | |||
| - | < | ||
| <?php | <?php | ||
| include(' | include(' | ||
| ?> | ?> | ||
| - | </ | ||
| + | Instead, set parameters locally and include the file: | ||
| - | so you have some parameters here. You can pass it as | ||
| - | |||
| - | < | ||
| <?php | <?php | ||
| $_GET[' | $_GET[' | ||
| Line 57: | Line 50: | ||
| include(' | include(' | ||
| ?> | ?> | ||
| - | </ | ||
| + | This approach passes parameters and keeps the include local rather than remote. | ||
| - | ===== Close site for some countries ===== | ||
| - | Example | + | ===== Deny access |
| + | |||
| + | Use .htaccess: | ||
| < | < | ||
| RewriteEngine on | RewriteEngine on | ||
| - | RewriteCond %{ENV: | + | RewriteCond %{ENV: |
| RewriteRule ^$ http:// | RewriteRule ^$ http:// | ||
| </ | </ | ||
| + | ===== Rotate pages for returning visitors ===== | ||
| + | |||
| + | When the same visitor returns to your niche site from different sources, you can show them different page designs. For example, show design 1 to first-time visitors and designs 2, 3, etc. to repeat visitors. | ||
| + | |||
| + | Configure this in Settings > CJ Pages by adding multiple design paths, one per line: | ||
| + | |||
| + | < | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | On the visitor' | ||
| + | |||
| + | If you use internal rotation, you have two options: | ||
| + | |||
| + | **Option 1: Automatic rotation in Rotation > Tube > Tube Settings** | ||
| + | |||
| + | Enable the option to rotate pages for repeat visitors. The system works as follows: | ||
| + | - When a returning visitor (one who came from within your site) visits the index, they see the 2nd page design | ||
| + | - If they' | ||
| + | - For categories: if they arrive directly and have already seen that category page, they see the next design | ||
| + | |||
| + | Note: This rule only applies if the referrer is your own domain. This ensures that when a visitor clicks from the homepage to a category thumbnail, they see that design on the category page. | ||
| + | |||
| + | **Option 2: Create separate page files** | ||
| + | |||
| + | Create multiple PHP files like: | ||
| + | |||
| + | < | ||
| + | domain/ | ||
| + | |||
| + | <?php | ||
| + | $_GET[' | ||
| + | include('/ | ||
| + | |||
| + | domain/ | ||
| + | <?php | ||
| + | $_GET[' | ||
| + | include('/ | ||
| + | ?> | ||
| + | |||
| + | and set CJPages to: | ||
| + | |||
| + | / | ||
| + | / | ||
| + | (and so on) | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Direct links for topsites ===== | ||
| + | |||
| + | If you link directly to traders instead of using out.php, you can still count clicks using AJAX. | ||
| + | |||
| + | Here's an example topsite template: | ||
| + | |||
| + | < | ||
| + | <a target=_blank href=' | ||
| + | </ | ||
| + | |||
| + | This renders as: | ||
| + | |||
| + | < | ||
| + | <a target=_blank href=' | ||
| + | </ | ||
| + | |||
| + | The links are direct. To count these clicks, add AJAX code to track them: | ||
| + | |||
| + | < | ||
| + | |||
| + | <script src='/ | ||
| + | |||
| + | <script type=" | ||
| + | $(document).ready(function(){ | ||
| + | $(' | ||
| + | $(this).on(' | ||
| + | $.get('/ | ||
| + | { | ||
| + | }, | ||
| + | function(data) { | ||
| + | } | ||
| + | ); | ||
| + | |||
| + | |||
| + | }); | ||
| + | }); | ||
| + | |||
| + | }); | ||
| + | |||
| + | </ | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | Key points: | ||
| + | - Replace YOUR_FOLDER with your actual folder path | ||
| + | - Each link has class=' | ||
| + | - A click event is attached to this class: $(' | ||
| + | |||
| + | ===== Page tracking ===== | ||
| + | |||
| + | You can track which pages receive traffic and how visitors move through your site. In Trade > Statistics > Page Track, you'll see two columns: | ||
| + | |||
| + | - **Inbound Views:** Traffic from outside your site (external referrer) | ||
| + | - **Local Views:** Traffic from within your site (internal referrer) | ||
| + | |||
| + | You can track pages in two ways: | ||
| + | |||
| + | **Option 1: URL parameter** | ||
| + | |||
| + | Add & | ||
| + | |||
| + | **Option 2: Template tags** | ||
| + | |||
| + | Use template tags in your HTML: | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| - | ===== Count productivity from feeders ===== | ||
| - | There' | ||
| - | The easiest way is to switch on the option "add notrade as feed traders" | ||
hints.1459098667.txt.gz · Last modified: (external edit)
