User Tools

Site Tools


new_rotation_hints

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
new_rotation_hints [2014/04/01 16:43] – [Thumb rolling] adminnew_rotation_hints [2026/04/20 13:55] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== New Rotation Hints  ====== +====== New Rotation Hints ======
  
 ===== Setting GET parameters  ===== ===== Setting GET parameters  =====
  
-This is one the most important things to understand. As mentioned in [[New Rotation Templates#How it works]] all the ages are not static, but generated 'on-the-fly' by the same script and you get different results based on request parameters and templateFor example /scj/tube/index.php?group_name=phones outputs all images from 'phonesgroup, and /scj/tube/index.php?group_name=cars - from groups 'cars'But on site you can use links like /category/phones/ and /category/cars/thanks to mod_rewrite+This is one of the important points that you must definitely understand, because it is used in many places below 
 +As already mentioned in [[New Rotation Templates#How it works]] all pages in new rotation are formed by essentially one script and different results are obtained depending on input parameters. Roughly speaking /scj/tube/index.php?group_name=phones will display thumbs of the phones group, and /scj/tube/index.php?group_name=cars - will display thumbs of the cars groupAlthough on the site it will look like /category/phones/ and /category/cars/clean URLs are provided by rewrites ([[New Rotation Faq#What is mod_rewrite]])
  
-In this example /scj/tube/index.php?group_name=phones group_name=phones is a GET parameter.+In this example /scj/tube/index.php?group_name=phones specifically group_name=phones are GET parameters
  
-What you are supposed to understand after reading this information is how to pass parameters to /scj/tube/index.php and there are few ways to do it.+The main thing to understand in this section is: you can pass parameters to the script /scj/tube/index.php in different ways.
  
 **Option 1** **Option 1**
  
-Direct url to /scj/tube/index.php?group_name=phones . +Direct when you write it like this /scj/tube/index.php?group_name=phones.  
 +The only detail here is how query parameters are written: after the file name comes a ? (question mark), and parameters are separated by & (ampersand).
  
-**2 - rewrites**+**Option 2 - Via rewrites**
  
-Lets say we want to output group 'phones' using template 'super_template' , direct URL - /scj/tube/index.php?group_name=phones&force_template=super_template  +For example we want to display the phones group with a specific template. In option 1 this would look like /scj/tube/index.php?group_name=phones&force_template=super_template which is not very nice. So we write a rewrite
- +
-Rewrite +
  
   RewriteRule ^super_phones\.html$ /scj/tube/index.php?group_name=phones&force_template=super_template   RewriteRule ^super_phones\.html$ /scj/tube/index.php?group_name=phones&force_template=super_template
  
-and you get an URL like this - http://yourdomain/super_phones.html.+and the URL will be beautiful - http://yourdomain/super_phones.html.
  
-**3 - file **+**Option 3 - via file**
  
-The same task for /scj/tube/index.php?group_name=phones&force_template=super_template.  +The rewrite option is good, but it has 2 problems: there are sites without Apache, i.e. purely on nginx for example, which doesn't read .htaccess files and accordingly the rewrites written there don't work. And if there are very many rewrites it starts to put load on the CPU.  
-Create file super_phone.php + 
 +Besides, it's harder to make flexible conditions in rewrites, so there is option 3. 
 + 
 +Same task: a beautiful link for /scj/tube/index.php?group_name=phones&force_template=super_template. Create file super_phone.php with the content 
  
 <code> <code>
Line 36: Line 38:
 </code> </code>
  
-and you get URL like  http://yourdomain/super_phones.php+and we get a beautiful URL http://yourdomain/super_phones.php
  
-===== Different titles =====+Another advantage of this option is that parameters can be adjusted directly in PHP for conditions not covered by the script, for example:
  
-There are some tricks to get different titles for pages generated using the same template.+<code> 
 +<?php 
 +$_GET['group_name'] = 'phones';
  
-For example  'sort' : domain/category/asd/1/ctr/ and domain/category/asd/1/date+// here we change the template depending on the referrer 
 +if ($_SERVER['HTTP_REFERER'] == 'google') { 
 +   $_GET['force_template'] = 'super_template_for_google'; 
 +} else { 
 +   $_GET['force_template'] = 'super_template_for_traders'; 
 +}
  
 +include('./scj/tube/index.php');
 +</code>
 +
 +
 +
 +
 +===== How to sort by date by default, effectively with no homepage rotation, like a regular tube =====
 +
 +* Create a main.php file on the domain root that looks like 
 <code> <code>
-<?php if ($_GET['order'== 'ctr'{?>+<?php 
 +$_GET['order'] = 'date'; 
 +include('./scj/tube/index.php')
 +</code> 
 +  * Write the PATH (NOT URL!!!) to this file in Settings - CJPages (before this, you probably had the path to scj/tube/index.php written there - delete this line, there should be only 1 line left with the path to main.php) 
 +  * That's all.
  
-<title>Site order by CTR </title> 
  
-<?php } elseif ($_GET['order'== 'date'{ ?>+===== How to organize a trade in groups using the new rotation (rewrite=====
  
-<title>Site order by date </title>+First, how traffic gets from the trader to you:
  
-<?php } else { ?>+**The trader has a multi-niche website:**  
 +  * The easiest way is to set up a redirect to the desired niche using a referrer (this is in [[Tube CMS Pages#redirects]]) 
 +  * There you can also configure custom words if the names of the trader’s niches do not coincide strongly with yours
  
-<title>Default order (default = by ctr ) </title>+**The trader has a single-niche website**  
 +  * or his domain contains a niche keyword, which is a fairly common situation and he will be redirected to the desired niche anyway 
 +  * or add its domain to custom niche redirects
  
 +All. You don't need to do anything else for simple options.
 +
 +**If for some unknown reason auto-redirect does not suit you and you want the old-style with setting up each trader separately, then the options are as follows:**
 +  - create rewrite for example
 +  RewriteRule ^niche\.php$ /?niche_name=niche
 +  and ask the trader to send http://yourdomain/niche.php
 +  - option 2 is to create a file for example niche.php like 
 +<code>
 +<?php
 +$_GET['group_id'] = 21; // this is the id of the rotation niche
 +include('./scj/tube/index.php');
 +</code>
 +and then either the trader immediately sends to http://yourdomain/niche.php or we go to the trader’s edit and set niche.php to him as a personal page.
 +
 +
 +If you use any of the complex options, please describe why. We need to add an example of why this might be necessary.
 +
 +
 +**Now sending traffic out by groups.**
 +
 +
 +**Option 1**
 +
 +* Create groups for the trade, the name of the trade group must match the name of the rotation groups. In Update 45, a special button even appeared in rotation - groups, which copied the names of groups.
 +  * add rewrite. As you can see, the group is taken into account in the link to the out
 +<code>
 +RewriteRule ^gal/(.*)/(.*)/index.html?(.*)$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&group=$1&url=content&slug=$3
 +</code>
 +  * and change the subtemplate used to display thumbs, so that the links would be something like this
 +<code>
 +a href='/gal/<!--GROUP_NAME-->/<!--GALLERY_SLUG-->/index.html?<!--THUMB_LINK-->'
 +</code>
 +
 +
 +It’s not difficult to notice that the group name is transmitted via rewrite.
 +
 +**Option 2**
 +
 +Update 48 introduced the Trade by groups feature
 +
 +We have a classic multi-niche CJ site, we want to trade in groups. To do this, you need to add &group=... to the URL, however, for tube site with rewrites this is not as convenient and beautiful as we would like. If by default the links look like /gallery/cool_gal/index.html, then to trade by group we need to do something like /gallery/current_group/cool_gal/index.html + change rewrite a little so that the group parameter is passed to the out. For those who find this difficult, there is another option.
 +
 +If you use default rewrite, it means that your category pages have a URL like /category/123/asian/ or simply /category/asian/, which means that if a person clicks in this category, then when out, we can determine in which category the click was made by the referrer, and depending on the category, send it to different groups of traders.
 +
 +To use this feature, you need to:
 +
 +- If you have not created them yet, then create trade groups with names as rotation categories. By the way, you can do this with one click in Rotation - Groups (Copy To Trade Groups)
 +  - Distribute traders into groups
 +  - Rotation - CMS - Tube settings enable Niche trade option
 +  - that's it :)
 +
 +
 +
 +**Option 3**
 +
 +Usually there are quite a few niches on a multi-niche CJ site, more than the number of niches in which I would like to distribute traders, for example, 500 niches in rotation, but I would like to distribute traders into only 15 groups.
 +
 +* Create groups for trade, let’s say the same 15 pieces, the names may or may not coincide with the names of the rotation groups - it doesn’t matter.
 +  * in the rotation groups, find the custom var1 field and for each rotation group, enter the name of the trade group that will be used
 +  * add rewrite. As you can see, the group is taken into account in the link to the out
 +<code>
 +RewriteRule ^gal/(.*)/(.*)/index.html?(.*)$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&group=$1&url=content&slug=$2
 +</code>
 +  * and change the subtemplate used to display thumbs, so that the links would be something like this
 +<code>
 +a href='/gal/<!--GROUP_CUSTOM_VAR1-->/<!--GALLERY_SLUG-->/index.html?<!--THUMB_LINK-->'
 +</code>
 +
 +
 +===== Thumbs' Rolling  =====
 +
 +Thumb rolling means taking, for example, 5 thumbs from one gallery into rotation to find the best one. You can also make thumbs roll on mouse hover within a gallery. This approach has been developed in tubes, but this has not yet happened in pix sites ([[http://demo.smartcj.com/cat/14/7%20Demo2%20%20Taylor/ctr/1/content_list_pic/image/|example for a picture gallery]], you need to hover over any thumb and wait a split second) and of course the same option [[http://demo.smartcj.com/cat/14/7%20Demo2%20%20Taylor/ctr/1/content_list_mov/movie/|for movie galleries]].
 +
 +It's very easy to do:
 +  * we add JS code to the template, which arranges the roll for all pictures whose ID starts with rot 
 +<code>
 +
 +<script src='/scj/includes/js/jquery.js'></script>
 +
 +<script>
 +$(document).ready(function() {
 +
 + $("img[id^=rot]").bind('mouseenter', function() {
 + $(this).attr('rotating', 1);
 + StartSlide($(this).attr('id'));
 + }).mouseleave(function() {
 + $(this).attr('rotating', 0);
 +        if ($(this).attr('original_src')) $(this).attr('src', $(this).attr('original_src'));
 + });
 +
 +});
 +
 +
 +function StartSlide(id) {
 + if (!$('#' + id).attr('rotating') || $('#' + id).attr('rotating') == 0) return false;
 +
 +    if (!$('#' + id).attr('original_src')) $('#' + id).attr('original_src', $('#' + id).attr('src'));
 +
 + var images = $('#' + id).attr('original_src') + ',' + $('#' + id).attr('rel');
 +    images = images.split(',');
 +    var cur = $('#' + id).attr('current_img');
 +
 +    cur = parseInt(cur);
 +    cur = (!cur || cur == 0) ? 1 : (cur+1);
 +
 +    cur = (!images[cur]) ? 0 : cur;
 +    $('#' + id).attr('current_img', cur);
 +
 +  var preload = new Image();
 +
 + if (cur == 0) {
 + preload.src = $('#' + id).attr('original_src');
 + } else {
 + preload.src = images[cur];
 + }
 +
 +    if ($('#' + id).attr('rotating')) setTimeout("ChangeSRC('"+id+"', '"+preload.src+"')", 700);
 +
 +}
 +
 +function ChangeSRC(id, src) {
 + if (!$('#' + id).attr('rotating') || $('#' + id).attr('rotating') == 0) return false;
 + $('#' + id).attr('src', src);
 +    StartSlide(id);
 +}
 +</script>
 +
 +</code>
 +
 +* here is a role for thumb whose ID starts with 'rot'. The sub will look something like this:
 +<code>
 +
 +<a href="/gallery/<!--SAFE_DESC-->/<!--GALLERY_ID-->/index.html?<!--THUMB_LINK-->" title="<!--ALT-->">
 +<img id='rot<!--GALLERY_ID-->' src="<!--THUMB_URL-->" class="t_img" alt="" rel="<!--ALL_THUMBS-->" />
 +</a> 
 +</code>
 +
 +Rolling is based on two things: 
 +<code>
 +id='rot<!--GALLERY_ID-->' - the script rolls only thumbs whose ID starts with rot 
 +rel="<!--ALL_THUMBS-->" - here the script lists all available thumbs for this gallery
 +</code>
 +
 +
 +===== Custom pagination =====
 +
 +In mysql there are 2 options for sampling from the database: when the total number of results for a query is counted and when not. The second option is faster. Accordingly, when there is no <pagination macro, the script thinks that exact numbers are not needed, for example prev\next is used, and makes the request the 2nd option.
 +
 +Therefore, if you need your own navigation and the exact number of TOTAL_ITEMS, you need to insert something like
 +
 +<code>
 +
 +<!--
 +<pagination>
 +.
 +</pagination>
 +-->
 +
 +</code>
 +
 +There is still a pagination macro, but it is inside an HTML comment, so the script will still calculate <!--TOTAL_ITEMS-->, and you can use that number in your own code.
 +
 +You can make any one to your taste. For example
 +
 +<code>
 +
 +$total_pages = ceil(<!--TOTAL_ITEMS-->/100);
 +for ($i = 1; $i <= $total_pages; $i++) {
 +echo "<a href='/?page={$i}'>{$i}</a>";
 +}
 +</code>
 +
 +where 100 is the number of thumbs you have on your page (you will add it, since you build the template yourself). This is a simple example, of course you can diversify it as you need for a specific page.
 +
 +
 +**Option 2**
 +
 +In most cases, surfers don’t need the 25th page at all and people don’t go there in most cases, so it makes sense to limit them to, for example, 5 or 10 pages and just fit them into the template as is
 +
 +<code>
 +<ul class="pages">
 +<li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/1/" title="1">1</a></li>
 +<li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/2/" title="2">2</a></li>
 +<li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/3/" title="3">3</a></li>
 +</ul>
 +
 +For beauty, you can select the current page, for example
 +
 +<li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/1/" title="1"> 1 here </a></li>
 +add the code and it turns out
 +<li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/1/" title="1"> <? if ($_GET['page'] == 1) ? '<b>1</b>' : '1' ?> </a></li>
 +and the same for the remaining pages.
 +
 +</code>
 +
 +
 +
 +===== Separate page for a list of categories =====
 +**Option 2
 +
 +First
 +**
 +
 +1. Create a custom template, for example cat_template, in which the categories themselves are displayed, for example 
 +<code>
 +<category order=clicks num=1-20>
 +<a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/1/?<!--THUMB_LINK-->" title="<!--CATEGORY_NAME-->"><img src="<!--THUMB_URL-->" class="t_img" alt="" /></a>
 +</category>
 +</code>
 +
 +
 +2. this page will be visible via the link /scj/tube/?force_template=cat_template
 +
 +3. to get a beautiful link, add rewrite
 +<code>
 +RewriteRule ^categories$ /?force_template=cat_template
 +</code>
 +
 +and the page will open at the link domain.com/categories
 +
 +
 +**Option 2**
 +
 +1. Create a custom template, for example cat_template, in which the categories themselves are displayed, for example 
 +<code>
 +<category order=clicks num=1-20>
 +<a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/1/?<!--THUMB_LINK-->" title="<!--CATEGORY_NAME-->"><img src="<!--THUMB_URL-->" class="t_img" alt="" /></a>
 +</category>
 +</code>
 +
 +2. create a file categories.php at the root of the domain in which
 +<code>
 +<?php
 +$_GET['force_template'] = 'cat_template';
 +include('./scj/tube/index.php');
 +</code>
 +
 +
 +3. The page is available at the link domain.com/categories.php
 +
 +
 +===== Sitemap =====
 +
 +By default, you have a sitemap in scj/sitemap.php, but if suddenly for some reason it’s not there, then
 +
 +1. Create a sitemap template (starting from update 46 it is included in the default templates) with content like
 +<code>
 +<!--default_1-1000-->
 +</code>
 +
 +and subtemplate in accordance with the sitemap format.
 +
 +2. create a sitemap.php file on the domain root 
 +<code>
 +<?php
 +
 +define('CACHE_TIME', 86400);
 +$_GET['force_template'] = 'sitemap';
 +$_GET['skip_cell_settings'] = true; // skips cell K calculation - saves a bit of CPU time
 +// $_GET['custom_galleries'] = true; // uncomment this line if you need only custom galleries in site map
 +header('Content-Type: application/xml');
 +include('./scj/tube/index.php');
 +</code>
 +
 +
 +Please note that if you use descriptions that contain special characters, for example & (ampersand), then you must use CDATA in the template (if you don’t know what this is, it makes sense to open Google).
 +
 +__Considering that this point in the docs could have been written quite a long time ago relative to the time you read it, it makes sense to check Google docs again regarding the sitemap rules.__
 +In addition, Google’s rules say that the sitemap size should not be more than a certain amount, so if you have more than 1-2-3k gallery, then in any case you need to divide it into pages by ?page=1 ?page=2, etc. (see [[New Rotation Hints#setting_get_paramaters]]
 +
 +===== How to make RSS =====
 +
 +1. Create an rss template (starting from update 47 it is in the default templates) with content like
 +<code>
 +<thumb num=1-100> template for rss </thumb>
 +</code>
 +
 +and subtemplate in accordance with the rss format.
 +
 +2. create a file rss.php on the root of the domain 
 +<code>
 +<?php
 +
 +define('CACHE_TIME', 86400);
 +$_GET['force_template'] = 'rss';
 +$_GET['skip_cell_settings'] = true; // skips cell K calculation - saves a bit of CPU time
 +include('./scj/tube/index.php');
 +</code>
 +
 +
 +
 +===== Custom title for each template =====
 +
 +For example, you include the header template in all templates, so if you want different titles for different pages, you have the following options:
 +
 +Option depending on template
 +
 +<code>
 +
 +<?php 
 +if ('<!--TEMPLATE_NAME-->' == 'index' { ?> 
 +This is index
 +<? } elseif ('<!--TEMPLATE_NAME-->' == 'content_list') { ?>
 +This is category 
 +<? } elseif ('<!--TEMPLATE_NAME-->' == 'content_search') { ?>
 +this is search
 +<? } else { ?>
 +some other page
 +<? } ?>
 +
 +
 +</code>
 +
 +Depending on the variables passed to the URL
 +
 +<code>
 +<html>
 +<?php if ($_GET['gallery_id']) {?>
 +<title>This is custom gallery , display gallery description here for example <!--DESCRIPTION--></title>
 +<?php } elseif ($_GET['group_id']) { ?>
 +<title>This is category page, use here <!--GROUP_NAME--></title>
 +<?php } else { ?>
 +<title>This is index, any other desc here</title>
 <?php } ?> <?php } ?>
  
 +</code>
 +
 +
 +
 +
 +
 +
 +===== How to separate content by type =====
 + 
 +For example, we need to display only movies on some page. To do this, you need to add content_type=movie to the parameters
 +
 +<code>
 +http://domain.com/scj/tube/?group_id=5 - all content from group 5
 +http://domain.com/scj/tube/?group_id=5&content_type=movie - only movies from group 5
 +
 +You can also use image and flash
 +</code>
 +
 +All this also works through the file
 +
 +<code>
 +<?php
 +$_GET['group_id'] = 5;
 +$_GET['content_type'] = 'movie';
 +include('./scj/tube/index.php');
 +</code>
 +
 +
 +===== Separate template for a specific category =====
 +
 +Before making a separate template, think about it: maybe you don’t need a separate template, but just use custom vars for categories and thus solve this issue. However, if you are sure that you need a completely different page, then you can do it as follows:
 +
 +- Rotation - CMS pages - create a new template for example cat_new.tpl
 +  - in common.php we write the following (after <? )
 +<code>
 +if ($_GET['group_id'] == '1' or $_GET['group_name'] == 'group_name') $_GET['force_template'] = 'cat_new';
 +where 1 and group_name are the corresponding ID and name of the category you need
 +</code>
 +
 +===== Blog on a subdomain =====
 +
 +- Create a subdomain, copy common.php, index.php, as well as 2 directories scj/cgi and scj/tube to the root + create .htaccess as usual
 +  - In the basic admin panel we create templates, for example blog_index, blog_content_list, etc.
 +  - We got 3 komons, so as not to get confused, we’ll do the same in all 3
 +<code>
 +After <? add
 +
 +if ($_SERVER['REQUEST_URI'] == '/') {
 +$_GET['force_template'] = 'blog_index';
 +} elseif (isset($_GET['group_id'])) {
 +$_GET['force_template'] = 'blog_content_list';
 +}
 +</code>
 +
 +
 +===== Skimming on custom galleries =====
 +
 +In version 46, a new option has been added - skimming to gallery.
 +
 +Rotation - CMS - Tube Settings can be set **custom gallery skimming** for example in the form 
 +<code>
 +100%,70%trader.com,70%sponsor,50%sponsor_join,100
 +
 +first click on the content (100 and 100% are the same, you can write it as you wish)
 +second: 70% content, rest acc. 30% - /scj/cgi/out.php?member=trader.com,
 +3rd: 70% content 30% sponsor (on the URL that is registered with the sponsor in the site url)
 +4th: 50% content 50% sponsor (URL - join url),
 +5 and onwards - 100% content
 +</code>
 +
 +Please note that this only works if you link not directly to the content, but through a script, for example
 +
 +<code>
 +<a href='/gallery/<!--SAFE_DESC-->/<!--GALLERY_MD5-->/1.html'><img src='<!--IMG_1_THUMB-->'></a>
 +</code>
 +
 +
 +===== Niche traffic selling =====
 +
 +Many people sell traffic on exchanges. When purchasing, the exchange only takes into account the domain and for multi-niche domains the price of traffic is usually lower than for niche ones, however, it is possible to send traffic indicating a niche and in this case the exchange can give a higher bid.
 +
 +<code>
 +For example, usually everyone sells traffic using the link http://brocker.com/in.cgi?your_id 
 +In this case, if you have a multi-niche, your traffic is considered multi-niche traffic.
 +But the exchange provides the opportunity to send traffic like http://brocker.com/in.cgi?your_id&niche=test, where test is a niche. Such traffic is already considered niche and may cost more.
 +</code>
 +
 +To do this, we add the {GROUP} parameter to the sales URL; the URL looks like http://brocker.com/?id=your_id&niche={GROUP} (for example, for the holder http://www.trafficholder.com/in/in.php?yourid-{GROUP}). However, the question is that the broker does not have a Japanese niche? the closest one is for example tube_asian. To do this, in Rotation - CMS - Tube settings there is a Niche traffic sell field in which we need to enter the correspondence between our niches and the broker’s niches, for example,
 +
 +  tube_asian=Japanese,Asian 
 +  
 +where tube_asian is the broker’s niche, and Japanese,Asian are our niches on the site, separated by a comma.
 +
 +
 +
 +
 +===== PHP in navigation =====
 +
 +As you know, you can use PHP in template. And of course, it can be used in navigation to display, for example, some category in a different color, or somehow highlight it, or not display a category, etc.
 +
 +<code>
 +
 +by default it looks something like this
 +<navigation>
 +<a href="/category/<!--CATEGORY_NAME-->/" title="<!--PAGE_NUM-->"><!--PAGE_NUM--></a>
 +</navigation>
 +
 +Let's say we need to highlight the girls category with color
 +
 +<navigation>
 +<? if ('<!--CATEGORY_NAME-->' == 'girls') { ?>
 +<a href="/category/<!--CATEGORY_NAME-->/" title="<!--PAGE_NUM-->"><font color='pink'><!--PAGE_NUM--></font></a>
 +<? } else { ?>
 +<a href="/category/<!--CATEGORY_NAME-->/" title="<!--PAGE_NUM-->"><!--PAGE_NUM--></a>
 +<? } ?>
 +</navigation>
 +
 +
 +Let's say we need to skip the girls category in this list
 +
 +<navigation>
 +<? if ('<!--CATEGORY_NAME-->' != 'girls') { ?>
 +<a href="/category/<!--CATEGORY_NAME-->/" title="<!--PAGE_NUM-->"><font color='pink'><!--PAGE_NUM--></font></a>
 +<? }  ?>
 +</navigation>
 +
 +</code>
 +
 +===== Extra Thumb =====
 +
 +For design, it is sometimes convenient to have 2 sizes of thumb rotation, for example, to show large thumbs on the index, and smaller ones on category pages.
 +
 +To make the script create larger images for the index, create a crop profile with larger dimensions in Rotation - Settings - Crop Profile, and specify that profile in the Extra Thumb field during grabbing. In that case the script creates two thumbs: one regular thumb, for example /scj/thumbs/123/456.jpg, and a second one from the same source using the other crop profile, for example /scj/thumbs/123/456.jpg.extra.jpg
 +
 +You can use this in a template like this: usually we display thumb as
 +
 +  <img src='<!--THUMB_URL-->'> 
 +
 +If you made an extra thumb, then you can display it as follows:
 +
 +  <img src='<!--EXTRA_THUMB_URL-->'>
 +
 +
 +
 +
 +===== How to make a personal template for a trader in the new rotation =====
 +  - Create a template in Rotation - CMS pages, for example trd_tpl
 +  - Create a file for example trd_tpl.php at the root of the domain with the following content
 +
 +<code>
 +<?php
 +$_GET['force_template'] = 'trd_tpl';
 +include('./scj/tube/index.php');
 +</code>
 +
 +and write the PATH (!NOT URL!!!) to this file in the trader edit.
 +
 +===== How to remove the rotation parameter from links (1x23x456) =====
 +
 +Relevant only for script version 1.x
 +
 +In version 2.x there is a magic rotation parameter, when nothing is needed in the links
 +
 +Typically links look like this:
 +
 +  /gallery/cool_gallery/index.html?12x34x56
 +
 +12x34x56 are rotation parameters, the goal is to get rid of this in the URL so that it looks more aesthetically pleasing.
 +
 +You can do it like this:
 +
 +1. In the sub, your links look something like this:
 +
 +<code>
 +<a href="/gallery/<!--GALLERY_SLUG-->/index.html?<!--THUMB_LINK-->"> <img ...> </a>
 +
 +replace with
 +
 +<a href="/gallery/<!--GALLERY_SLUG-->/index.html" rot_id='<!--THUMB_LINK-->'> <img ...> </a>
 +
 +</code>
 +
 +no matter how difficult it is to notice, we put <!--THUMB_LINK--> in the rot_id parameter
 +
 +
 +2. add to <head>
 +
 +<code>
 +<script type="text/javascript" src="/scj/includes/js/jquery.js"></script>
 +<script type="text/javascript">
 +$(document).ready(function(){
 + $('a[rot_id]').each(function(){
 + $(this).bind('click', function(){
 +     if ($(this).attr('href').indexOf('?') == -1) $(this).attr('href', $(this).attr('href')+ '?' + $(this).attr('rot_id'));
 + });
 + });
 +});
 +
 +</script>
 +</code>
 +
 +
 +===== I don't like links like /gallery/cool/index.html?123x45x678 =====
 +
 +
 +There are 2 types of “dislikes” here - the /gallery view itself, etc. - this changes in rewrite.
 +
 +2nd option - I don’t like that 123x45x678 is right after the URL, it changes there, etc.
 +
 +Here are the options:
 +
 +1. If you don’t like that the surfer sees it - http://smartcj.com/wiki/doku.php?id=new_rotation_hints#%D0%BA%D0%B0%D0%BA_%D1%83%D0%B1%D1%80%D0%B0%D1%82%D1%8C_%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80_%D1%80%D0%BE%D1%82%D0%B0%D1%86%D0%B8%D0%B8_%D0%B8%D0%B7_%D0%BB%D0%B8%D0%BD%D0%BA%D0%BE%D0%B2_1x23x456
 +
 +2. For CE - http://smartcj.com/wiki/doku.php?id=custom_galleries_and_google
 +
 +3. For CE there is also another option - to make links like
 +
 +  /gallery/cool/index.html?link=images/123x45x678
 +
 +and in GWT declare that link is an insignificant parameter and Google can ignore it.
 +
 +To do this, in .htaccess we replace places like
 +
 +out.php?link=images/%{QUERY_STRING}
 +  on 
 +  out.php?%{QUERY_STRING}
 +  In the template we change it to 
 +  http://domain/gallery/<!--GALLERY_SLUG-->/index.html?link=images/<!--THUMB_LINK-->
 +
 +
 +
 +**Option 2 of changing the end of links**
 +
 +In rewrite we change
 +
 +<code>
 +RewriteCond %{QUERY_STRING} ^(.+)$ 
 +RewriteRule ^gallery/([^/]+)/index.html$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&url=content&slug=$1 [L]
 +</code>
 +
 +on
 +
 +<code>
 +RewriteCond %{QUERY_STRING} ^param=(.+)$
 +RewriteRule ^gallery/([^/]+)/index.html$ /scj/cgi/out.php?link=images/%1&url=content&slug=$1 [L]
 +</code>
 +
 +As you can see, param has been added here, which can be disabled in GWT
 +
 +Accordingly, links should be made like
 +
 +  href="/gallery/<!--GALLERY_SLUG-->/index.html?param=<!--THUMB_LINK-->
 +
 +
 +
 +**Option 3 if you want a completely different look**
 +
 +At the moment, the <!--THUMB_LINK--> tag produces conditionally 12x34x56, for example, you want it to be &a=12&b=34&c=56 or for example &ppp=12.34.56, etc., in a word, some other type.
 +
 +<code>
 +
 +you do it in saba
 +
 +$my_var = explode('x', '<!--THUMB_LINK-->');
 +
 +you get an array
 +
 +Array
 +(
 +[0] => 12
 +[1] => 34
 +[2] => 56
 +)
 +
 +</code>
 +
 +and you can form a link from it as you wish
 +
 +for example option with a b c
 +
 +<code>
 +
 +out.php?url=....&a=<?=$my_var[0]?>&b=<?=$my_var[1]?>&c=<?=$my_var[2]?>
 +
 +and in common.php the parameter is added back
 +
 +if (isset($_GET['a'])) {
 +$_GET['link'] = 'images/' . $_GET['a'] . 'x' . $_GET['b'] . 'x' . $_GET['c'];
 +}
 +
 +</code>
 +
 +In this way, you can make parameters with any names or dots; in a word, your imagination is not limited in any way.
 +
 +
 +===== How to display all pages in navigation =====
 +
 +Typically navigation (aka pagination) looks something like this: 1 2 3 ... 40 41 42.
 +
 +If you need to display all 42 without... you need to replace the navigation with something like the following
 +
 +<code>
 +
 +Was
 +
 +<navigation>
 +<li><a href="/category/<!--CATEGORY_NAME-->/<!--SORT_ORDER-->/<!--PAGE_NUM-->/" title="<!--PAGE_NUM-->"><!--PAGE_NUM--></a></li>
 +</navigation>
 +
 +
 +replace it with
 +
 +<!--
 +commented out the current navigation without removing it from the template altogether
 +<navigation>
 +<li><a href="/category/<!--CATEGORY_NAME-->/<!--SORT_ORDER-->/<!--PAGE_NUM-->/" title="<!--PAGE_NUM-->"><!--PAGE_NUM--></a></li>
 +</navigation>
 +-->
 +
 +<?php
 +$thumbs_per_page = 200;
 +$total_pages = ceil(<!--TOTAL_ITEMS-->/$thumbs_per_page);
 +
 +for ($i = 1; $i <= $total_pages; $i++ ) {
 +?> 
 +<li><a href="/category/<!--CATEGORY_NAME-->/<!--SORT_ORDER-->/<?php echo $i?>/" title="<?php echo $i?>"><?php echo $i?></a></li>
 +<?php }?>
 +
 +
 +
 +where $thumbs_per_page = 200; accordingly, the number of thumbs per page in your template.
 </code> </code>
  
Line 64: Line 744:
 ===== Rating ===== ===== Rating =====
  
-Add styles+To add a custom gallery rating you need (using the example of content_custom_pic) 
 + 
 +Add styles to make the stars beautiful
  
 <code> <code>
Line 83: Line 765:
  
  
-Add JS script to make stars selectable +Add JS script that will beautifully do mouseover for stars
  
 <code> <code>
Line 96: Line 778:
  $.get('/scj/tube/index.php',  $.get('/scj/tube/index.php',
  {  {
- 'content_id': '<!--GALLERY_MD5-->',+ 'gallery_id': '<!--GALLERY_ID-->',
  'action': 'rating',  'action': 'rating',
  'rating': value  'rating': value
Line 112: Line 794:
  
  
-adding stars ..+We add the stars themselves
  
 <code> <code>
Line 126: Line 808:
  
  
-That's it. +All.
- +
- +
-PS To output rating use <!--RATING--> - it's a number so you can show in any way you want it. +
- +
-for example+
  
 +PS You can display the rating anywhere with the tag <!--RATING--> - this will be a number from which you can get anything.
 +the simplest example in the sub
 <code> <code>
 <? if(<!--RATING--> > 0) echo '*' ?>  <? if(<!--RATING--> > 0) echo '*' ?> 
Line 140: Line 819:
 <? if(<!--RATING--> > 4) echo '*' ?>  <? if(<!--RATING--> > 4) echo '*' ?> 
 </code> </code>
- 
  
  
 ===== Rating +1\-1 like\dislike ===== ===== Rating +1\-1 like\dislike =====
  
-and other 2-options rating systems +And other 2-variant ratings. 
- +The idea is simple: reduce the rating scale to two values, 1 and 2. In practice, 1 means dislike and 2 means like. So an average of 1.5 means 50/50 split between likes and dislikes, while 1.75 means 75% like and 25dislike.
-Actually the trick is simple: we leave only 2 options to choose. It's gonna be 1 and 2. Lets say 1 means "dislike", and 2 - "like". So if average is 1.5 that means 50% of visitors like it. 1.75 means 75% like25 dislike. It should be clear.+
  
-What to do:+Technical implementation:
  
-Add JS script +Add JS script that will post the voting result
 <code> <code>
  
-<script src='/scj/includes/js/jquery.js' type="text/javascript"></script> +<script src='/scj/includes/js/jquery.js' type="text/javascript"></script> THIS IS ONLY NEEDED 1 TIME, IF YOU ALREADY HAVE IT IN THE TEMPLATE THEN YOU DO NOT NEED TO INSERT IT A 2ND TIME
  
 <script> <script>
Line 161: Line 838:
 $.get('/scj/tube/index.php', $.get('/scj/tube/index.php',
  {  {
- 'content_id': '<!--GALLERY_MD5-->',+ 'gallery_id': '<!--GALLERY_ID-->',
  'action': 'rating',  'action': 'rating',
  'rating': value  'rating': value
Line 169: Line 846:
  }  }
 ); );
- 
 } }
  
Line 175: Line 851:
 </code> </code>
  
-Adding vote buttons+Adding voting buttons and rating output
  
 <code> <code>
Line 188: Line 864:
 </div> </div>
  
-+1 and  -1 can be replaced with whatever you want.++1 and -1 are replaced with fingers, checkmarks, etc.
  
 </code> </code>
  
  
-That's it )+All.
  
 +===== PHP code in template =====
  
-===== Rotating thumbs of a gallery  =====+As you probably know, you can use PHP code in templates. Of course, it will not be possible to consider all the nuances of the language in one example, and apparently it is not necessary, but I would like to show small example. For example, we need to display the desk tag <!--DESCRIPTION--> and we decided to make it all in capital letters, in PHP it’s very simple:
  
-Thumbs rolling is when we have lets say 5 thumbs from the same gallery and when you hover mouse cursor over a thumb it starts to show the rest of those 5 thumbs. Take look at demo here [[http://demo.smartcj.com/cat/14/7%20Demo2%20%20Taylor/ctr/1/content_list_pic/image/|example]])  and [[http://demo.smartcj.com/cat/14/7%20Demo2%20%20Taylor/ctr/1/content_list_mov/movie/|example 2]].+change <!--DESCRIPTION--> to <?php echo strtoupper('<!--DESCRIPTION-->')?> 
 +   
 +However, there is one important caveat: if the description contains a quote, you will get something like <?php echo strtoupper('masha's super pic')?>, which breaks the string and causes PHP errorFor that reason, this direct approach is safe only if you are sure the value cannot contain quotesIn all other cases, use the prefixes described in [[new_rotation_templates#tag_prefix]]
  
-How to do it +<code>     
-  * add JS code into your template , it rotates thumbs with id starting with 'rot_' +An example with <!--DESCRIPTION--would look like:
-<code>+
  
-<script src='/scj/includes/js/jquery.js'></script>+<?php echo strtoupper('<!--ESCAPED_DESCRIPTION-->')?
  
-<script> +</code 
-$(document).ready(function() { +
-  +
- $("img[id^=rot]").bind('mouseenter', function() { +
- $(this).attr('rotating', 1); +
- StartSlide($(this).attr('id')); +
- }).mouseleave(function() { +
- $(this).attr('rotating', 0); +
-        if ($(this).attr('original_src')) $(this).attr('src', $(this).attr('original_src')); +
- });+
  
-}); 
  
  
-function StartSlide(id) { +===== Comments =====
- if (!$('#' + id).attr('rotating') || $('#' + id).attr('rotating'== 0) return false;+
  
-    if (!$('#' + id).attr('original_src')) $('#' + id).attr('original_src', $('#' + id).attr('src'));+It's just as easy to add comments.
  
- var images = $('#' + id).attr('original_src') + ',' + $('#' + id).attr('rel'); +Add code that will post a comment without reloading the page (AJAX)
-    images = images.split(','); +
-    var cur = $('#' + id).attr('current_img');+
  
-    cur = parseInt(cur); +<code>
-    cur = (!cur || cur == 0) ? 1 : (cur+1);+
  
-    cur (!images[cur]) ? 0 : cur; +<script src='/scj/includes/js/jquery.jstype="text/javascript"></script> ---- this line is not required if jquery is already included somewherefor example in the rating.
-    $('#' + id).attr('current_img', cur);+
  
-  var preload = new Image(); 
  
- if (cur == 0) { +<script> 
- preload.src = $('#' + id).attr('original_src'); +function post_comment() {
- } else { +
- preload.src = images[cur]; +
- }+
  
-    if ($('#' + id).attr('rotating')) setTimeout("ChangeSRC('"+id+"', '"+preload.src+"')", 700); + $.post( 
 + '/scj/tube/', 
 +
 + 'action': 'add_comment', 
 + 'gallery_id': '<!--GALLERY_ID-->', 
 + 'captcha': $('#captcha').val(), 
 + 'username': $('#username').val()
 + 'comment': $('#comment').val() 
 + }, 
 + function(data) { 
 + if (data != 'OK'
 + $('#comment_error').text(data); 
 + } else { 
 +    $('#comment_error').text(' '); 
 +        $('#add_comment').html('Thank you ! Your comment will be reviewed by admin.'); 
 +         }
  
-+
- + );
-function ChangeSRC(id, src) { +
- if (!$('#' + id).attr('rotating') || $('#' + id).attr('rotating') == 0) return false; +
- $('#' + id).attr('src', src); +
-    StartSlide(id);+
 } }
 </script> </script>
Line 256: Line 926:
 </code> </code>
  
-  * adding rot_ id to thumbs (changing subtemplate)+ 
 +Adding an HTML comment form 
 <code> <code>
  
-<a href="/gallery/<!--SAFE_DESC-->/<!--GALLERY_ID-->/index.html?<!--THUMB_LINK-->" title="<!--ALT-->"> +<div id='comment_error'></div> 
-<img id='rot<!--ID-->' src="<!--THUMB_URL-->class="t_img" alt="" rel="<!--ALL_THUMBS-->" /> +<div id='add_comment'> 
-</a+<div class="clear"></div> 
 +<h4>Add comment</h4> 
 + 
 +<FORM name="add_comment" method="POST"> 
 + 
 +<div class="r_line"> 
 +<label>Name:</label> <input class="s_input" type="text" name='username' id='username' value="<?=$user['username']?>"> 
 +</div> 
 +<div class="r_line"> 
 +<label>Comment:</label> <textarea class="s_text" class="ph2" name='comment' id='comment' rows=5 cols=35 value="Leave Your Comments Here"></textarea> 
 +</div> 
 + 
 +<? if ($rot_settings['tube_comment_captcha']) {  ?> 
 +<div class="r_line"> 
 +<label>Captcha:</label><div class="clear"></div><img src="/scj/tube/captcha.php" id="captcha_img" width="158" height="60" alt="Visual CAPTCHA/> 
 +<input id='captcha' class="s_input" type="text" name='captcha' value="" /> 
 +</div> 
 +<div class="r_line"> 
 +<input type='button' value='Post Comment' onClick='post_comment();'> 
 +</div> 
 +<? } ?
 +</div> 
 + 
 +</form> 
 </code> </code>
  
-notice 2 points here+ 
 +and add the output of existing comments 
 <code> <code>
-id='rot<!--ID-->' - script rotates only those thumbs that has id starting with 'rot' + 
-rel="<!--ALL_THUMBS-->here script enumerates all available thumbs for this gallery+<!--TOTAL_COMMENTS--> 
 + 
 +<comments num=1-10> 
 +<!--DATE--> <!--USERNAME--> : <!--COMMENT--> 
 +</comments> 
 </code> </code>
  
  
-===== Internationalization ( i18 ) =====+All.
  
-it's pretty easy to translate site's menu (links like Most popular, Longest Videos and so on) into different languages. 
  
-1. Create custom template 'languages' with set of words like+===== Geo targeting ===== 
 + 
 +In fact, this is an example of PHP code in templates
  
 <code> <code>
-<?php  +<? 
-$my_keywords['en'] = array( +if ($_SERVER['GEOIP_COUNTRY_CODE'] == 'GB') { 
-  'most_popular' ='Most popular', +?>
-  'order_by_date' ='Order By Date', +
-  and so on +
-);+
  
-$my_keywords['es'] = array( +banner code 1
-  'most_popular' => 'Lo más leído', +
-  'order_by_date' => 'Ordenar por Fecha', +
-  and so on +
-);+
  
 +<? } else { ?>
  
-$my_keywords['de'] = array( +banner code 2
-  'most_popular' => 'Populärste', +
-  'order_by_date' => 'Sortiert nach Datum', +
-  and so on +
-);+
  
-and so on as many languages as you want.+<? } ?>
  
-Now you have 2 options to setup language for each user+</code>
  
-using browser language 
  
-if (strstr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'es')) { +===== Two indexes with different content types =====
-  $lang $my_keywords['es']; +
-} elseif (strstr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 'de')) { +
-  $lang $my_keywords['de']; +
-} else $lang $my_keywords['en'];+
  
-or geo_ip+Suppose you need two pages, one for movie content and one for image content. For example: movies.php and images.php
  
-if ($_SERVER['GEOIP_COUNTRY_CODE'] =='SP') { +Option 2
-  $lang = $my_keywords['es']; +
-} elseif ($_SERVER['GEOIP_COUNTRY_CODE'] =='DE') { +
-  $lang = $my_keywords['de']; +
-} else $lang = $my_keywords['en'];+
  
 +1. We do everything on one template
  
-Hopefully those examples are pretty self explaining +* create 2 files of the form  
 +<code> 
 +<?php 
 +$_GET['content_type'] = 'image'; // for the second file 'movie' 
 +include('./scj/tube/index.php'); 
 +</code> 
 +  * we register any of these pages in CJ Pages - this will be the site index  
 +  * since template is not specified here, index will be used 
 +  * if in your design you somehow work differently with different sizes of movie and picture thumbs, then for processing use code like this  
 +<code> 
 +<?php 
 +if ($_GET['content_type'] == 'image') { 
 +?> 
 +text 1 
 +<? 
 +} else  
 +?> 
 +testct 2 
 +<? 
 +}
  
-at the ens of template you can add a cookie+Please note that this code can be used both in the sub and in the template itself. 
 +Accordingly, links for pagination will be movies.php?page=2, etc.
  
-if ($_GET['set_lng'] and isset($my_keywords[$_GET['set_lng']])) { +</code>
-  setcookie('force_lng', $_GET['set_lng'], time() + 86400); +
-  $lang = $my_keywords['en']; +
-} elseif ($_COOKIE['force_lng'] and isset($my_keywords[$_COOKIE['force_lng']])){ +
-  $lang = $my_keywords[$_COOKIE['force_lng']]; +
-}+
  
-That's it for this template+ 
 +Option 2. We make 2 different templates, for example index_movies and index_images with the desired design and navigation, as well as 2 view files 
 + 
 +<code> 
 +<?php 
 +$_GET['content_type'] = 'image'; // for the second file 'movie' 
 +$_GET['force_template'] = 'index_images'; // for the second file 'index_movies' 
 +include('./scj/tube/index.php');
 </code> </code>
  
-2. Now you have to include this template into each template where you are going to use those words+ 
 +===== Translation of the site menu (i18) ===== 
 + 
 +It’s quite easy to translate the site menu (those links like Most Popular, Order By date, etc.) into other languages. 
 + 
 +Rotation - CMS Templates - Tpl Custom Var add custom variables, for example most_popular, this variable can be used in templates like <!--CUSTOM_VAR_MOST_POPULAR-->, and you can set a separate translation for each language. 
 + 
 + 
 +===== Another flash player ===== 
 + 
 +By default in the script there is a free player Jwplayer, at the moment it is already a bit old player, but it works :) If you want any other player, then the main thing is that you need to understand that the player and the script are not connected in any way. The script generates an HTML page where it replaces tags and how the page is displayed depends on the browser. How the movie plays depends on the player. 
 + 
 +By default the code is as follows
  
 <code> <code>
-<!--INCLUDE_TEMPLATE_languages-->+<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="<!--FLV_WIDTH-->" height="<!--FLV_HEIGHT-->"> 
 + <param name="movie" value="/scj/tube/player/player.swf" /> 
 + <param name="allowfullscreen" value="true" /> 
 + <param name="allowscriptaccess" value="always" /> 
 + <param name="flashvars" value="file=<!--FLV_URL-->&image=<!--FLV_THUMB_URL-->" /> 
 + <embed 
 + type="application/x-shockwave-flash" 
 + id="player2" 
 + name="player2" 
 + src="/scj/tube/player/player.swf"  
 + width="<!--FLV_WIDTH-->"  
 + height="<!--FLV_HEIGHT-->" 
 + allowscriptaccess="always"  
 + allowfullscreen="true" 
 + flashvars="file=<!--FLV_URL-->&image=<!--FLV_THUMB_URL-->"  
 + /> 
 + </object> 
 </code> </code>
  
 +As you can see, the player /scj/tube/player/player.swf is called and the parameters flashvars="file=<!--FLV_URL-->&image=<!--FLV_THUMB_URL-->" are passed to it. 
 +You can put your player anywhere convenient, any player, change the template so that it loads your player, just check how it needs to pass parameters. For example, Kernel player
  
-3. and replace words in templates with variables 
 <code> <code>
-Most popular ->  <?=$lang['most_popular']?+ 
-Order By Date -> <?=$lang['order_by_date']?> +<object id="kt_player" name="kt_player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="600" height="400"> 
-and so on+    <param name="allowscriptaccess" value="always"/
 +    <param name="allowFullScreen" value="true"/> 
 +    <param name="movie" value="http://%YOUR_DOMAIN_HERE%/player/kt_player.swf"/> 
 +    <param name="flashvars" value="video_url=<!--FLV_URL-->&amp;preview_url=<!--FLV_THUMB_URL-->"/> 
 +    <embed src="http://%YOUR_DOMAIN_HERE%/player/kt_player.swf?video_url=<!--FLV_URL-->&amp;preview_url=<!--FLV_THUMB_URL-->" width="600" height="400" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/> 
 +</object>  
 </code> </code>
  
-From this point it should work as it supposed to. 
  
-4. Now we want to add an ability for user to force switch to a selected language +===== How to quickly create a blog using an existing database ===== 
 + 
 +If you filled the database well initially and you have good descriptions and a custom gallery is highly desirable, then you can create a parallel blog for the site in 10 minutes. 
 + 
 +* create a subdomain conditionally blog.yourdomain.com 
 +  * set this to the smartcj subdomain 
 +  * make it slave yourdomain.com 
 +  * download [[http://smartcj.com/wiki/local_upload/SCJ_templates.example.49.sql|blog templates ]] 
 +  * upload this file to Rotation - CMS (at the bottom Upload Templates) 
 + 
 +That's it, the blog is ready :) 
 + 
 + 
 +===== Suggestions Based on logged searches ===== 
 + 
 +Auto-suggestions when the user starts to enter search based on what was previously searched 
  
 <code> <code>
-add a link like  
  
-http://domain/?force_lng=de (and so on any language based on your language array $my_keywords['de'])+<script type="text/javascript" src="/scj/includes/js/jquery.js"></script> This may already be on the page. 
 +<script type="text/javascript" src="/scj/includes/js/jquery.autocomplete.min.js"></script> This script does the autocompletion 
 + 
 + 
 +<script> 
 + $(document).ready(function(){    
 +        $('#search_field').autocomplete({ 
 +         serviceUrl'/scj/tube/index.php?force_template=search_suggest&zero_items_to_404=off', /* This template will be below*/ 
 + 
 +            onSelect: function(suggestion, data) { 
 +        $('#search_field').val(suggestion.value); 
 +        } 
 +        }); 
 + }); 
 +</script>
  
 </code> </code>
 +  
  
 +some styles for beauty
 +  
 +<code>
 +<style>
 +.autocomplete-suggestions { border: 1px solid #999; background: #FFF; cursor: default; overflow: auto; }
 +.autocomplete-suggestion { padding: 2px 5px; white-space: nowrap; overflow: hidden; }
 +.autocomplete-selected { background: #F0F0F0; }
 +.autocomplete-suggestions strong { font-weight: normal; color: #3399FF; }
 +</style>
 +</code>
  
-That's it. 
  
 +the search field itself
  
-===== Comments =====+<code> 
 +<input class=inputbox value='' type="text" size="30" id="search_field"> <br> 
 +</code>
  
-Adding AJAX code to add comments+The template 'search_suggest' itself
  
 <code> <code>
 +<?php
 +header('Content-Type: application/json');
 +?>{
 +"query":"<!--ESCAPED_GET_QUERY-->",
 +"suggestions":[
 +{"value":"","data":""}
  
-<script src='/scj/includes/js/jquery.js' type="text/javascript"></script> ---- don't use this string twice+<search_log num=1-10 skip_search_log=true search=GET_query> 
 +,{"value":"<!--ESCAPED_SEARCH_QUERY-->","data":"<!--ESCAPED_SEARCH_QUERY-->"
 +</search_log>
  
 +]}
 +</code>
 +
 +How to check: /scj/tube/index.php?force_template=search_suggest&zero_items_to_404=off&query=... should produce results with those searches that are already in the database
 +
 +
 +===== Suggestions : Based on regular search =====
 +
 +The same as above, but it suggests not by the search database, but by the gallery database
 +
 +
 +styles
 +
 +<code>
 +<style>
 +.autocomplete-suggestions { border: 1px solid #999; background: #FFF; cursor: default; overflow: auto; }
 +.autocomplete-suggestion { padding: 2px 5px; white-space: nowrap; overflow: hidden; }
 +.autocomplete-selected { background: #F0F0F0; }
 +.autocomplete-suggestions strong { font-weight: normal; color: #3399FF; }
 +</style>
 +</code>
 +
 +
 +a field
 +
 +<code>
 +<input class=inputbox value='' type="text" size="30" id="search_field"> <br>
 +</code>
 +
 +
 +JS code 
 +
 +<code>
 +<script type="text/javascript" src="/scj/includes/js/jquery.js"></script>
 +<script type="text/javascript" src="/scj/includes/js/jquery.autocomplete.min.js"></script>
 <script> <script>
-function post_comment() {+ $(document).ready(function(){    
 +  
 +        $('#search_field').autocomplete({ 
 +         serviceUrl: '/scj/tube/index.php?force_template=gallery_search_suggest',
  
- $.post( +        onSelectfunction(suggestion, data) { 
- '/scj/tube/', +                location.href suggestion.data
-+        
- 'action''add_comment', +        }); 
- 'content_id': '<!--GALLERY_ID-->', + 
- 'captcha': $('#captcha').val(), + 
- 'username': $('#username').val(), + });
- 'comment': $('#comment').val() +
- }, +
- function(data) { +
- var t = data.split('|'); +
- if (t[0] == 'ERROR') { +
- $('#comment_error').text(t[1])+
- else { +
- $('#comment_error').text(' '); +
-     $('#add_comment').html('Thank you ! Your comment will be reviewed by admin.'); +
-     }+
  
- } 
- ); 
-} 
 </script> </script>
 +</code>
  
 +
 +template 'gallery_search_suggest'
 +
 +
 +<code>
 +<?php
 +header('Content-Type: application/xml');
 +?>{
 +"query":"<!--ESCAPED_GET_QUERY-->",
 +"suggestions":[
 +{"value":"","data":""}
 +
 +<thumb skip_search_log=true search=GET_query num=1-10>
 +,{"value":"<!--ALT-->","data":"/gallery/<!--GALLERY_SLUG-->/index.html"}
 +</thumb>
 +
 +]}
 </code> </code>
  
  
-Add html form+As you can see, the only difference is that in the template itself, specifically in the <thumb tag 
 + 
 +===== Site with main niches ===== 
 + 
 +Let's say we want to create a site with 3 main categories (general (id 1), gay (2) and shemale (3)), each of these categories has sub-niches (typically teen, mature, etc.). They should be specifically for subcategories (in editing a category there is a parent category field) 
 + 
 +/?category_id=1 - will display only what is in category 1 AND(!) subgroups 
 +   
 +For example, if he searches by tag and it is necessary from category 1 then 
 + 
 +  /?tag=...&category_id=1 
 +   
 +   
 + 
 +**Category thumbs** 
 + 
 +You can create 3 sets of thumb categories just for this situation 
 + 
 +Settings - System Thumbs  
 + 
 +When displaying thumb categories, we can indicate the set number 
 + 
 +  <category num=1-10 set_id=2  
 +   
 +Please note that the set can also be passed in a URL 
 + 
 +  <category num=1-10 set_id=GET_set_id  
 +  
 + 
 + 
 +===== Custom flv: content separation ===== 
 + 
 +Let's imagine that we have a gallery with 3 flash movies, like this http://babesfarm.com/caprice/movies/kitchen_fuck05/index01.html 
 + 
 +If you make a custom gallery out of it, but if you do it just like that, you will get a gallery with 3 movies (in the gallery template, the sponsor cleverly made direct links to movies for scripts that do not know how to rob flash content), 3 flash movies and all this will be on one page. And we want each of the movies to open on a separate page, like with pixelated content. 
 + 
 +**How ​​to do it:** 
 + 
 +1. Let’s create a new template for the flash gallery, where on the gallery page there will only be a thumb of this gallery (like the pix one), the movies themselves will be played on a separate page (again, like the pix gallery), let’s say it will be called **content_flv_gallery** and its template will be
  
 <code> <code>
 +<a href='/scj/tube/?slug=<!--GALLERY_SLUG-->&force_template=content_flv_single_item&item_id=1'><img src='<!--FLASH_1_THUMB-->'></a>
 +<br>
 +<a href='/scj/tube/?slug=<!--GALLERY_SLUG-->&force_template=content_flv_single_item&item_id=2'><img src='<!--FLASH_2_THUMB-->'></a>
 +<br>
 +<a href='/scj/tube/?slug=<!--GALLERY_SLUG-->&force_template=content_flv_single_item&item_id=3'><img src='<!--FLASH_3_THUMB-->'></a>
 +<br>
 +</code>
  
-<div id='comment_error'></div> +As it’s not difficult to notice, there is no flash player and all thumbs point to /scj/tube/?slug=<!--GALLERY_SLUG-->&force_template=content_flv_single_item&item_id=...
-<div id='add_comment'> +
-<div class="clear"></div> +
-<h4>Add comment</h4>+
  
-<FORM name="add_commentmethod="POST">+where there is another template **content_flv_single_item** where the flash player will be, as well as item_id - where the number of the movie from the gallery is transmitted, which should be played. 
 + 
 +**Content content_flv_single_item** 
 + 
 +<code> 
 +<? if ($_GET['item_id'] == 1)  { ?>  
 +<div class="flash"> 
 + <div class="player"> 
 + 
 +<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="playerwidth="<!--FLASH_1_THUMB_X-->height="<!--FLASH_1_THUMB_Y-->"> 
 + <param name="movie" value="/scj/tube/player/player.swf" /> 
 + <param name="allowfullscreen" value="true" /> 
 + <param name="allowscriptaccess" value="always" /> 
 + <param name="flashvars" value="file=<!--FLASH_1_IMAGE-->&image=<!--FLASH_1_THUMB-->" /> 
 + <embed 
 + type="application/x-shockwave-flash" 
 + id="player2" 
 + name="player2" 
 + src="/scj/tube/player/player.swf"  
 + width="<!--FLASH_1_THUMB_X-->"  
 + height="<!--FLASH_1_THUMB_Y-->" 
 + allowscriptaccess="always"  
 + allowfullscreen="true" 
 + flashvars="file=<!--FLASH_1_IMAGE-->&image=<!--FLASH_1_THUMB-->"  
 + /> 
 + </object>
  
-<div class="r_line"> 
-<label>Name:</label> <input class="s_input" type="text" name='username' id='username' value="<?=$user['username']?>"> 
-</div> 
-<div class="r_line"> 
-<label>Comment:</label> <textarea class="s_text" class="ph2" name='comment' id='comment' rows=5 cols=35 value="Leave Your Comments Here"></textarea> 
 </div> </div>
  
-<? if ($rot_settings['tube_comment_captcha'])  ?> +<? } ?> 
-<div class="r_line"> + 
-<label>Captcha:</label><div class="clear"></div><img src="/scj/tube/captcha.phpid="captcha_imgwidth="158height="60alt="Visual CAPTCHA" /> + 
-<input id='captcha' class="s_input" type="text" name='captcha' value="" /> + 
-</div+ 
-<div class="r_line"> +<? if ($_GET['item_id'== 2)  ?>  
-<input type='button' value='Post Comment' onClick='post_comment();'>+<div class="flash"> 
 + <div class="player"> 
 + 
 +<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="<!--FLASH_2_THUMB_X-->" height="<!--FLASH_2_THUMB_Y-->"> 
 + <param name="movie" value="/scj/tube/player/player.swf/> 
 + <param name="allowfullscreenvalue="true/> 
 + <param name="allowscriptaccessvalue="always" /> 
 + <param name="flashvars" value="file=<!--FLASH_2_IMAGE-->&image=<!--FLASH_2_THUMB-->/> 
 + <embed 
 + type="application/x-shockwave-flash" 
 + id="player2" 
 + name="player2" 
 + src="/scj/tube/player/player.swf"  
 + width="<!--FLASH_2_THUMB_X--> 
 + height="<!--FLASH_2_THUMB_Y-->" 
 + allowscriptaccess="always"  
 + allowfullscreen="true" 
 + flashvars="file=<!--FLASH_2_IMAGE-->&image=<!--FLASH_2_THUMB-->"  
 + /> 
 + </object> 
 </div> </div>
 +
 <? } ?> <? } ?>
 +
 +
 +
 +<? if ($_GET['item_id'] == 3)  { ?> 
 +<div class="flash">
 + <div class="player">
 +
 +<object id="player" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="player" width="<!--FLASH_3_THUMB_X-->" height="<!--FLASH_3_THUMB_Y-->">
 + <param name="movie" value="/scj/tube/player/player.swf" />
 + <param name="allowfullscreen" value="true" />
 + <param name="allowscriptaccess" value="always" />
 + <param name="flashvars" value="file=<!--FLASH_3_IMAGE-->&image=<!--FLASH_3_THUMB-->" />
 + <embed
 + type="application/x-shockwave-flash"
 + id="player2"
 + name="player2"
 + src="/scj/tube/player/player.swf" 
 + width="<!--FLASH_3_THUMB_X-->" 
 + height="<!--FLASH_3_THUMB_Y-->"
 + allowscriptaccess="always" 
 + allowfullscreen="true"
 + flashvars="file=<!--FLASH_3_IMAGE-->&image=<!--FLASH_3_THUMB-->" 
 + />
 + </object>
 +
 </div> </div>
  
-</form>+<? } ?>
  
 </code> </code>
  
 +there are 3 almost identical pieces that differ only <? if ($_GET['item_id'] == 1) { ? and accordingly the number of the substituted tag <!--FLASH_1_THUMB-->
  
-and output existing comments+ 
 + 
 + 
 +**2. Grabbed gallery** 
 + 
 +When grabbing content or later through editing, you need to set **Embed Template** for this gallery, respectively - content_flv_gallery 
 + 
 + 
 +**3. rewrite**  
 + 
 +URLs like /scj/tube/?slug=<!--GALLERY_SLUG-->&force_template=content_flv_single_item&item_id=1 don’t look particularly nice, so you can add rewrite for example
  
 <code> <code>
 +RewriteRule ^flash_gallery/([^/]+)/([0-9]{1,2}).html$ /scj/tube/?slug=$1&force_template=content_flv_single_item&item_id=$2&%{QUERY_STRING} [L]
 +</code>
  
-<!--TOTAL_COMMENTS-->+and accordingly replace content_flv_gallery in the template
  
-<comments num=1-10+<code> 
-<!--DATE--> <!--USERNAME--> : <!--COMMENT--> +links like  
-</comments>+<a href='/scj/tube/?slug=<!--GALLERY_SLUG-->&force_template=content_flv_single_item&item_id=1'><img src='<!--FLASH_1_THUMB-->'></a
 +on  
 +<a href='/flash_gallery/<!--GALLERY_SLUG-->/1.html'><img src='<!--FLASH_1_THUMB-->'></a> 
 +</code> 
 + 
 + 
 +**4. Features of this gallery** 
 + 
 +Her sponsor posted 2 types of links to contentthey are flash, others are in the form of links to movie clips for scripts that do not know how to rob flash content. This is correct, but the script will download both options, although we only want to output flash. For us, this is only bad because some of the content that we don’t need will be stored on disk. Accordingly, when adding content, you can set Add only this type of content - flash in the import. This will save some disk space. 
 + 
 +===== Navigation within one gallery ===== 
 + 
 +For example, we have a custom pix gallery with a certain number of images. Clicking on thumb opens not the picture itself, but a page with this picture plus some additional advertising, etc. You can put links on the same page to the following images of this gallery, for example 
 + 
 +<code> 
 + 
 +<? if ($_GET['item_id'] != 1) { ?> 
 +<a href='/gallery/<!--GALLERY_SLUG-->/<?=($_GET['item_id']-1)?>.html'> Prev </a
 +<? } ?> 
 + 
 +<? if ($_GET['item_id'] < <!--GALLERY_TOTAL_ITEMS--> ) { ?> 
 +<a href='/gallery/<!--GALLERY_SLUG-->/<?=($_GET['item_id']+1)?>.html'> Next </a> 
 +<? } ?>
  
 </code> </code>
  
 +If you have other rewrites, do not forget to edit the links.
  
-That's it. 
-Note that comment moderation available for paid versions only. 
  
 +===== Friendly tube =====
  
 +For content sites on the same base (master slave), there is an option to organize a trader among themselves, when the surfer sees the content but on another site in the network.
  
 +For example, a user clicks on http://domain1.com/gallery/gallery_slug/index.html, but the skim script decides to send him for a trade. In this case, the user does not see the gallery. If we send it to another site in our network, we can show it the gallery, but on a different domain.
  
 +This has a positive effect on the product of the original site (the person wanted to see the movie - he saw it), and also makes it possible to show other thumbs around the embed itself = the surfer can click on these thumbs on the trader’s site.
  
-===== Thumb rolling =====+To do this, on the domain1.com website for the domain2.com trader, specify the site type - Friendly Tube. In this case, if the script decides to send to this trader, then the script will send the slug gallery to the trader. Of course, only if the redirect to the trader occurred when they clicked on the content, and not in the toplist. The script will simply send those to http://domain2.com/ and add http://domain2.com/?try&slug=super_gallery. to the URL
  
-Let's say you have 5 thumbs for each galleryusually rotation engine tries to find the best one among them, but you can also "roll" those thumbs with mouseover ie thumbs will replace it other while mover cursor is over it.+On domain2.com, if of course SmartCJ is also installed there, the script sees this slug and does not open the site index, but redirects to the URL Try Param Redirect URL, which looks something like
  
-How to do it +  http://{DOMAIN}/gallery/{GET_slug}/index.html  
-  * Add some JS some that add rolling for all thumbs with швы starting with 'rot'+ 
 +those redirect to gallery. If you have your own rewrites, then you need to change the URL to match your rewrites. 
 + 
 +This is of course only relevant when  
 +  - if the trader also has SmartCJ  
 +  - if you use either master-slave (then the IDs are 100% the same) or if the content as a whole overlaps. 
 + 
 +If there is no gallery with this ID on the trader’s website, it will just be an index 
 + 
 + 
 + 
 +===== Custom links ===== 
 + 
 +Links to gallery in the default version /gallery/gallary_slug/index.html in order to change them you need to change rewrite + template so that the URLs for your rewrite are generated. 
 + 
 +Likewise for categories, tags, etc. 
 + 
 +The only special case here is category links such as /category/cool/date/1/. The word cool is the category name, but date is already a sort key, and the script must receive a sort value it understands. If you put something like new_galleries_first there, the script will not know how to interpret it. 
 + 
 +To change to this option you need to: 
 + 
 +Add to common.php (note: they should all be the same)
 <code> <code>
 +if (isset($_GET['order']) and $_GET['order'] == 'new_galleries_first') {
 +$_GET['order'] = 'date';
 +} elseif (isset($_GET['order']) and $_GET['order'] == 'long_galleries_first') {
 +$_GET['order'] = 'duration';
 +} else {
 +$_GET['order'] = 'ctr';
 +}
 +</code>
  
-<script src='/scj/includes/js/jquery.js'></script>+Now the /category/cool/new_galleries_first/1option will work as expected.
  
-<script> +Howeverin the navigation itself there is SORT_ORDERwhich is actually equal to $_GET['order']and we need our optionThereforewe also add our own variable to common.php
-$(document).ready(function() { +
-  +
- $("img[id^=rot]").bind('mouseenter'function() { +
- $(this).attr('rotating'1); +
- StartSlide($(this).attr('id')); +
- }).mouseleave(function() { +
- $(this).attr('rotating', 0); +
-        if ($(this).attr('original_src')) $(this).attr('src'$(this).attr('original_src')); +
- });+
  
-});+<code> 
 +if (isset($_GET['order']) and $_GET['order'] == 'new_galleries_first') { 
 +$_GET['order'] = 'date'; 
 +$GLOBALS['original_sort_name'] = 'new_galleries_first'; 
 +elseif (isset($_GET['order']and $_GET['order'] == 'long_galleries_first') { 
 +$_GET['order'] = 'duration'; 
 +$GLOBALS['original_sort_name'] = 'long_galleries_first'; 
 +} else { 
 +$_GET['order'] = 'ctr'; 
 +$GLOBALS['original_sort_name'] = 'best_galleries_first'; 
 +
 +</code>
  
 +And in the template, instead of SORT_ORDER, we use <?=$GLOBALS['original_sort_name']?>
  
-function StartSlide(id) { +PS In the navigation tag you need to add skip_href_deletion=true so that it does not clean up your PHP code.
- if (!$('#' + id).attr('rotating') || $('#' + id).attr('rotating') == 0) return false;+
  
-    if (!$('#' + id).attr('original_src')) $('#' + id).attr('original_src', $('#' + id).attr('src')); 
  
- var images $('#' + id).attr('original_src') + ',' + $('#' + id).attr('rel'); +===== Random keywords for galleries =====
-    images images.split(','); +
-    var cur $('#' + id).attr('current_img');+
  
-    cur = parseInt(cur)+If you have a list of keywords that you would like to randomly scatter throughout the gallery (for example, create a custom var and then use it somewhere in the gallery), then you can do it like this:
-    cur = (!cur || cur == 0) ? 1 (cur+1);+
  
-    cur = (!images[cur]? 0 : cur; +* create a text file with keywords (conditionally keywords.txt
-    $('#' + id).attr('current_img', cur);+  * PHP script kw.php
  
-  var preload new Image();+<code> 
 +<?php  
 +$lines file('/FULL/PATH/TO/keywords.txt'); 
 +echo $lines[rand(0, count($lines) -1)]; 
 +</code>
  
- if (cur == 0) { +* make sure that in the browser http://domain/kw.php displays a random string 
- preload.src = $('#' + id).attr('original_src'); +  * add import replacement of the form
- } else { +
- preload.src = images[cur]; +
- }+
  
-    if ($('#' + id).attr('rotating')) setTimeout("ChangeSRC('"+id+"', '"+preload.src+"')", 700); +<code> 
 +If this field  = URL 
 +Contains this value = http 
 +Then Search For = * 
 +in This Field = Custom field 1 
 +And Replace it With = external:http://domain/kw.php 
 +</code>
  
 +All.
 +
 +The main thing here is external:http://domain/kw.php, those custom var will receive the value that will be given by external:http://domain/kw.php.
 +
 +
 +===== Site with main niches =====
 +
 +Let's say we need to create a website with 3 main niches and X additional ones.
 +
 +Main niches: general (id 1), guy (2) and bumblebee (3)
 +and for example 100 niches like teen (id 4), amateur (id 5) and so on
 +
 +It is logical that if a person wants to see general, but most likely he does not want to see the rest 2 and 3. Those in categories 1, 2 and 3 should have global filtering.
 +
 +Thus, all galleries on our site end up in at least 2 categories: one of 1 2 3 and at least one of the others (in our example, 4 and 5).
 +
 +When outputting gallery, we can limit what the surfer wants to see. For example, he wants to see type (4) and only general (you need to exclude groups 2 and 3) - the link is obtained
 +
 +  /?group_id=4&skip_group_id=2,3
 +  
 +If you need to see a teen, but which is a guy in the group (this means you need to exclude 1 and 3), then the link will be
 +
 +  /?group_id=4&skip_group_id=1,3
 +
 +Using the same scheme, you can divide, for example, tags
 +
 +  /?tag=...&skip_group_id=1,3
 +
 +
 +**thumb categories:**
 +
 +Settings - System Thumbs you can configure the required number of thumb categories. 
 +In this case, we need 3 sets (sets) of thumb categories - for each of groups 1 2 and 3.
 +In order to filter thumb categories there is a field Skip group ids, comma separated
 +
 +For example, for category 1, in which we do not want to see the thumb from the categories guy and shemale, we should write 2,3. Set 2 we will have a guy, then we will exclude the groups general (1) and bumblebee (3), we will write 1.3 there.
 +
 +When displaying thumb categories, we can specify which set to display, for example, we will display set 2
 +
 +  <category num=1-10 set_id=2 
 +  
 +For convenience, the set number can be taken from the URL /?set_id=2
 +
 +  <category num=1-10 set_id=GET_set_id 
 +  
 +Since we don’t want to display the current group itself, the skip_group_id parameter will come in handy (when displaying set 2, we don’t need to display the group guy (2) itself) /?set_id=2&skip_group_id=2
 +
 +  <category num=1-10 set_id=GET_set_id skip_group_id=GET_skip_group_id
 +  
 +As you can see in this example, the category and set IDs match, so the tag can even be made
 +
 +  <category num=1-10 set_id=GET_set_id skip_group_id=GET_set_id
 +  
 +but to avoid confusion in the example of such a replacement, we will not do it.
 +
 +In addition, some categories may be specific to a certain niche and therefore there may not be a gallery there, so it makes sense to add min_gallery_count=1 so as not to display empty categories
 +
 +<category num=1-10 set_id=GET_set_id skip_group_id=GET_set_id min_gallery_count=1
 +
 +  
 +  
 +===== Content protection =====  
 +
 +By default, the content is in scj/thumbs/galleries/.../1.jpg and conditionally the movie for it is scj/thumbs/galleries/.../1.flv
 +
 +On the page we output <img src='/scj/thumbs/galleries/.../1.jpg'>, and in the movie player something like file: /scj/thumbs/galleries/.../1.flv
 +
 +And the surfer sees a direct link to /scj/thumbs/galleries/.../1.flv and can download the movie. For example, we decided to make the user’s life a little harder and prevent him from downloading via a direct link. How to do this (assuming we have nginx):
 +
 +1. first, in the nginx config, disable downloading files directly
 +
 +<code>
 +location ~* /scj/thumbs/galleries/.*\.(flv)$ {
 +   deny all;
 } }
 +</code>
  
-function ChangeSRC(id, src) +and add a secret location there too 
- if (!$('#+ id).attr('rotating') || $('#+ id).attr('rotating'== 0return false; + 
- $('#' + id).attr('src'src); +  location /protected 
-    StartSlide(id);+            root /var/www; 
 +            internal; 
 +  } 
 + 
 + 
 +2. Let's tweak the template a littleFor example now it looks something like this 
 + 
 +  <a href='<!--IMG_1_IMAGE-->'><img src='<!--IMG_1_THUMB-->'></a> 
 + 
 + 
 +which gives us approximately the following result 
 + 
 +  <a href='/scj/thumbs/galleries/482/850/1_201.flv'><img src='/scj/thumbs/galleries/482/850/1_t.jpg'></a> 
 + 
 +we will add /content.php?check=<?=time()?>&url= 
 + 
 +  <a href='/content.php?check=<?=time()?>url=<!--IMG_1_IMAGE-->'><img src='<!--IMG_1_THUMB-->'></a> 
 + 
 +and the result will be 
 + 
 +  <a href='/content.php?check=1511450638&url=/scj/thumbs/galleries/482/850/0_771.flv'><img src='/scj/thumbs/galleries/482/850/0_t.jpg'></a> 
 +   
 + 
 +3. create content.php 
 +   
 +<code> 
 +<?php 
 +if (!$_GET['check'] or $_GET['check'] < time(- 86400) { 
 + die("Error link");
 } }
 +
 +header("X-Accel-Redirect: /protected/" . $_GET["url"]);  
 +
 +</code>
 +
 +
 +In total, if you configured nginx correctly, then when you directly request /scj/thumbs/galleries/482/850/0_771.flv it should display 403.
 +
 +The link /content.php?check=1511450638&url=/scj/thumbs/galleries/482/850/0_771.flv should give the file, here 1511450638 is just unix time. It can be replaced with anything.
 +
 +===== Content when no content is found =====  
 +
 +For example, a person was looking for some keyword that you don’t have on your site, and he was given 0 search results. But you would like to show at least something.
 +
 +There are 3 options:
 +
 +
 +**First**
 +
 +By default, if nothing is found, it shows template content_not_found , but if you display it there
 +
 +  <thumb num=1-10 order=easy_random > 
 +
 +then these will be your random gallery
 +
 +
 +**Option 2**
 +
 +if you don’t want to change content_not_found then make a separate random_content template
 +
 +<code>
 +Nothing found , look at those links
 +
 +<thumb num=1-10 order=easy_random zero_items_to_404=off> .... 
 +
 +
 +</code>
 +
 +
 +and change the search template (content_search) as
 +
 +<code>
 +
 +
 +<?if (<!--TOTAL_ITEMS--> == 0) { ?>
 +
 +<script>
 +window.location.replace("https://yourdomain/?force_template=random_content"); (here of course we add which rewrite)
 </script> </script>
 +
 +<? } else { ?>
 +
 +display thumb as usual in search
 +
 +<? } ?>
 +
  
 </code> </code>
  
-  * add id='rot..' for all thubms in subtemplate like+ 
 +Nothing extra is added to this soup. 
 + 
 + 
 +**Option 3** 
 + 
 +Just change content_search like 
 <code> <code>
  
-<a href="/gallery/<!--SAFE_DESC-->/<!--GALLERY_ID-->/index.html?<!--THUMB_LINK-->" title="<!--ALT-->"> +<?if (<!--TOTAL_ITEMS--> == 0) { ?> 
-<img id='rot<!--ID-->' src="<!--THUMB_URL-->" class="t_img" alt="" rel="<!--ALL_THUMBS-->" /+ 
-</a+Nothing found , look at those links 
 + 
 +<thumb num=1-10 order=easy_random search="" zero_items_to_404=off....  
 + 
 + 
 +<? } else { ?> 
 + 
 +<thumb num=1-10 zero_items_to_404=off page_main_tag=true>....  
 +display thumb as usual in search 
 + 
 +<? } ?> 
 </code> </code>
  
 +This option is simpler, but the downside is that even if something is found, the <thumb num=1-10 order=easy_random> tag will be processed (php is reflected after the script macros) and this means a little more load.
  
-That's it. 
  
  
-Note. there are 2 points you have to understand+===== Last Visited Galleries =====   
 + 
 +This is an example of using cache in template and macros 
 + 
 +Add the following piece of code to the gallery template (for example content_page)
  
 <code> <code>
-id='rot<!--ID-->'JS tries to roll there thumbs only +Current gallery id: <!--GALLERY_ID--> <br><br><br> 
-rel="<!--ALL_THUMBS-->" - here script outputs all available thumbs for this gallery+ 
 +<? 
 + if ((int) '<!--GALLERY_ID-->') { 
 + $last_items Cache::get('last_items'); 
 +  
 + if (!$last_items) $last_items = array(); 
 + 
 + if ($last_items[0] != (int) '<!--GALLERY_ID-->') array_unshift($last_items, (int) '<!--GALLERY_ID-->'); 
 + $last_items array_slice($last_items, 0, 100, true); 
 + 
 + Cache::set('last_items', $last_items, 3600); 
 +
 + 
 +?> 
 + 
 + 
 +<thumb num=1-10 limit_by_gallery_id=true order=row gallery_id=CACHE_last_items cache_time=10>  
 + Last visited: <!--GALLERY_ID--><br> 
 +</thumb> 
 </code> </code>
  
  
-PS feel free to modify this code+Here you should note for yourself
  
 +- Cache::set('last_items', $last_items - add viewed IDs to cache
 +  - in the tag we display it, picking it up from cache <thumb num=1-10 limit_by_gallery_id=true **gallery_id=CACHE_last_items** order=row >  
 +  - added to the list of recently viewed only if there is one if ('<!--GALLERY_ID-->') {
 +  - but the list itself can also be displayed on the index
  
-===== Hide rotation parameter ===== 
  
-A regular link looks like +Here you need to understand that
  
-  /gallery/cool_gallery/index.html?12x34x56+- if you open a page without cache, then the list of recent ones will not be read (no cache) 
 +  - the cache page along with this list, if you looked at gallery ID 1 2 and 3, then for 3 in the last viewed there will be 1 and 2, but for 2, even if you open it again after 3, only 1 gallery 2 will be cached.
  
-where  12x34x56 - is rotation parameter. It this a way for the script to understand what thumb has been clicked, at what page and so on. You can hide it from surfer, here's how to do it  
  
-1In subtemplate you have something like +There are 2 options here: 
 + 
 +- leave it as it is because for a surfer it’s not so important 
 +  - reduce cache time (cache_time=100) 
 + 
 + 
 +===== Last Visited Galleries by Country =====   
 + 
 +Here we need a slightly deeper understanding of the process. 
 + 
 +You have a website page, so you don’t have to generate it for each surfer - it is generated and stored in cache for some time, so you don’t have to generate a new page for the next visitors. If we want to show as in the example above, but by country, we need to at least remake the page for each country, given that there are 190 countries in the world, which means we will need to generate 190 times more pages (for each country separately) 
 + 
 + 
 +To avoid this, you can go another way 
 + 
 +- for example, on the index we make a code that conditionally requests the last_viewed.php page and displays the content  
 +  - it turns out that the index will be the same for everyone and only last_viewed.php will need to be worked out 190 (according to the number of countries) 
 + 
 + 
 +How to do it step by step 
 + 
 +1. add gallery to the template
  
 <code> <code>
-<a href="/gallery/<!--GALLERY_SLUG-->/index.html?<!--THUMB_LINK-->"> <img ...> </a>+id: <!--GALLERY_ID-->
  
-replace it by  
  
-<a href="/gallery/<!--GALLERY_SLUG-->/index.html" rot_id='<!--THUMB_LINK-->'<img ...</a>+<
 + if ((int) '<!--GALLERY_ID-->') { 
 + 
 +     $cache_id = 'last_items_' $_SERVER['GEOIP_COUNTRY_CODE']; 
 + 
 + $last_items Cache::get($cache_id); 
 + 
 + $last_items[(int) '<!--GALLERY_ID-->'] = (int) '<!--GALLERY_ID-->'; 
 + $last_items = array_slice($last_items, 0, 100); 
 +  
 + Cache::set($cache_id, $last_items, 86400); 
 +  
 +
 + 
 + 
 +?>
  
 </code> </code>
  
-not that <!--THUMB_LINK--> has been moved to rot_id+here in the cache variable
  
 +  $cache_id = 'last_items_' . $_SERVER['GEOIP_COUNTRY_CODE'];
  
-2. add some JS code to <head> section of your template+the gallery list is added (last 100). As you can see, the variable depends on the country. 
 + 
 + 
 + 
 +2. create a new template viewed_in_country
  
 <code> <code>
-<script type="text/javascript" src="/scj/includes/js/jquery.js"></script> +<thumb num=1-10 limit_by_gallery_id=true gallery_id=CACHE_GET_last_viewed_cache_id order=row > 
-<script type="text/javascript">+ <!--GALLERY_ID--> ......<br> 
 +</thumb> 
 + 
 +</code> 
 + 
 +Pay attention to gallery_id=CACHE_GET_last_viewed_cache_id. This means the gallery_id list is taken from CACHE using the GET variable last_viewed_cache_id. 
 + 
 + 
 + 
 +3. where you need to display a gallery list for the current country 
 + 
 +<code> 
 + 
 +<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> 
 + 
 +last viewed in <?=$_SERVER['GEOIP_COUNTRY_CODE']?> 
 + 
 +<script language="JavaScript" type="text/JavaScript"> 
 $(document).ready(function(){ $(document).ready(function(){
- $('a[rot_id]').each(function(){ + 
- $(this).bind('click', function(){ + $.get('./?force_template=viewed_in_country&last_viewed_cache_id=last_items_<?=$_SERVER['GEOIP_COUNTRY_CODE']?>' , {}, 
-     if ($(this).attr('href').indexOf('?'== -1) $(this).attr('href', $(this).attr('href')+ '?' + $(this).attr('rot_id')); +  function(data
- }); +            $('#last_viewed').html(data); 
- });+   } 
 + ); 
 }); });
  
 </script> </script>
 +
 +<div id='last_viewed'></div>
 +
 </code> </code>
  
  
-And that's it. it will add the parameter on click only, so surfer won't see it on 'mouseover'+the main thing here is that we are requesting a URL
-===== How to change links /gallery/cool/index.html?123x45x678 =====+
  
-If you'd like to change links like /gallery to let's say /video - edit rewrites and templates.+./?force_template=viewed_in_country&last_viewed_cache_id=last_items_<?=$_SERVER['GEOIP_COUNTRY_CODE']?>
  
-if you'd like to change rotation parameter (?123x45x678  part) there are some options+where in the last_viewed_cache_id variable we pass from which cache id the gallery list should be taken, and this variable will be different for each country.
  
 +the resulting content is inserted into div = last_viewed
  
-1. Если не нравится, что это видит серфер - check 'hide Rotation Params' at this page+Total needed for the test
  
-2For SEO purposes - http://smartcj.com/wiki/doku.php?id=custom_galleries_and_google+* go to a couple of gallery for step 1 to work 
 +  * open in the browser ./?force_template=viewed_in_country&last_viewed_cache_id=last_items_US , here US is your country code - should display a list of gallery IDs where you were in the previous paragraph
  
-3. For google (another option) - make likes like  
  
-  /gallery/cool/index.html?link=images/123x45x678 
  
-and in Google webmaster's tools (GWT) set &linkk parameter as 'not important'+===== Master/Slave First Thumb =====  
  
 +The master and slave have the same gallery set since it is one database. This means we can arrange a trade between sites on the same base in such a way that when going to the trader, the first thumb matches the one on which the click was made. This should boost sales.
  
-In this case you should also change .htaccess+How to set it up: a simple version for clarity
  
-  out.php?link=images/%{QUERY_STRING} +1. on site A, surfer click on gallery 12345, when going to the trader (site B), we need to let site B know which gallery to show first (id 12345).  To do this, the out parameters must contain the ID of the gallery on which the click is made, for example
-  should be replaced by +
-  out.php?%{QUERY_STRING} +
-  for all occurrences  +
-   +
-  and template like +
-  http://domain/gallery/<!--GALLERY_SLUG-->/index.html?link=images/<!--THUMB_LINK-->+
  
 +<code>
 +<thumb num=1-10>
 +    <a href='/scj/cgi/out.php?show_gallery_id=<!--GALLERY_ID-->'>  click  <!--GALLERY_ID--> </a> <br>
 +</thumb>
 +</code>
  
-**Options 2 for rotation parameter**+As you can see here, the show_gallery_id= parameter is passed to out, the URLs will be like out.php?show_gallery_id=12345
  
-if you'd like to have something not '&link='  +2. On site A, change the URL of the trader (site B) (only those that are on the same database and will support this feature) 
 + 
 +  http://trader/?first_gallery_id={GET_show_gallery_id} 
 + 
 + 
 +Note the {GET_show_gallery_id} placeholder from step 1. When sending traffic to the trader, it is replaced with the value that was passed to out, so the trader receives a URL like http://trader/?first_gallery_id=12345 
 + 
 + 
 +3. add an index to the trader’s template
  
-in rewrites change 
  
 <code> <code>
-RewriteCond %{QUERY_STRING} ^(.+)$  + 
-RewriteRule ^gallery/([^/]+)/index.html$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&url=content&slug=$1 [L]+<thumb num=1 gallery_id=GET_first_gallery_id limit_by_gallery_id=true> 
 +    first gallery <!--GALLERY_ID--> <!--THUMB_URL--> <br> 
 +</thumb> 
 </code> </code>
  
-to + 
 +here you should note gallery_id=GET_first_gallery_id which is taken from point 2 
 + 
 + 
 +All. 
 + 
 + 
 + 
 +===== Rotate for Rows =====   
 + 
 +There is a useful rotation option 
 + 
 +  Rotate page for raws 
 +  ie if surfer visits us for a second time - show him second page instead of the first one  
 + 
 + 
 +If a surfer goes to the site’s index, then we can automatically change the &page= parameter, those on the first visit the user actually sees &page=1, on the second (when the user is no longer unique) &page=2 - those if your index displays just thumb 
 + 
 +  <thumb num=1-10> 
 +   
 +then on the first login the user will see thumb 1-10, on the 2nd thumb number 11 - 20. 
 + 
 + 
 +**If you have thumb categories on your index** then the situation is different and there are 2 options 
 + 
 +1. if, for example, you have only 100 categories, and you display 50 on the index 
 + 
 +  <category num=1-50 adjust_num_to_page=true 
 +   
 + 
 +then on the first run there will be categories 1 - 50, and on the second 51 - 100 
 + 
 + 
 + 
 +2. if you have only 100 categories and you display all 100 on the index 
 + 
 +  <category num=1-100 
 + 
 + 
 +in this situation, in order to show other thumbs, you need to create an additional set of thumb categories. To do this, in the settings of the Category thumbs rotation, turn on set 2 (and for example also set 3).  We get 3 sets of thumb categories. 
 + 
 + 
 +add the set number in the template 
 + 
 + 
 +  <category order=clicks num=1-10 set_id=GET_page> 
 +  <!--CATEGORY_NAME--> <!--THUMB_URL--> <br> 
 +  </category> 
 + 
 + 
 +Pay attention to set_id=GET_page. The script will then rotate three different sets of thumb categories. 
 + 
 + 
 +===== Custom Vars for Ads =====   
 + 
 +If the same ad insertion code is used then I often see something like 
 + 
 +1. create an ads template in which 
 + 
 +$ads = '<a href= .. > <img = .. '; 
 + 
 +2. in page templates it is added in different places 
 + 
 +<?=ads?> 
 + 
 + 
 +The problem is 
 + 
 +- the code is not cached and PHP is executed every time (such simple code does not add much load, but still) 
 +  - if you need to change advertising, you need to go to websites and edit the template, which is not very convenient 
 +  - the client can edit to something like $ads = 'Today's Deal!' ';  , get a PHP error due to incorrect quotes 
 + 
 + 
 +If you use Rotation - CMS -TPL Custom var then you can 
 + 
 +- get variables for template in the form of <!--CUSTOM_VAR_MY_VAR1--> tags that are cached 
 +  - There you can edit these custom tags on the entire network at once. Moreover, both all at once and individual tags. 
 +  - no problems with quotes 
 + 
 + 
 + 
 +===== Related From Another Domain  =====   
 + 
 +You can add traffic for your new domains if, for example, you include a link to gallery on your domains with traffic, for example 
 + 
 +* you have a domain And where there is a lot of traffic 
 +  * there is a new domain B  
 +  * on domain B we make a template like
  
 <code> <code>
-RewriteCond %{QUERY_STRING} ^param=(.+)$ + 
-RewriteRule ^gallery/([^/]+)/index.html/scj/cgi/out.php?link=images/%1&url=content&slug=$1 [L]+<thumb num=1-5> 
 +    <a href="http://domain_B/<!--GALLERY_SLUG-->/index.html"> <!--THUMB_URL--> </a> 
 +</thumb> 
 </code> </code>
  
-You can see 'param' here. So this is a way to use another word instead of 'link' 
  
-Don't forget about links+* and display the template on domain A for example like this
  
-  href="/gallery/<!--GALLERY_SLUG-->/index.html?param=<!--THUMB_LINK-->+  <iframe src="http://domain_B/?force_template=test" width="600" height="400"></iframe> 
 +   
 +   
 +Thus, on domain A there will be links directly to gallery from domain B, plus thumb from domain B will begin to receive CTR.
  
  
 +===== Sphinx Related Search  =====  
  
-**Option 3 if you want completely another style  ** +Advanced search with synonyms. For example, a user searches for “car”, but in our database it says “auto”, because the descriptions do not match - they will not be found. Sphinx has synonyms that solve this problem.
  
-Tag <!--THUMB_LINK--> outputs something like '12x34x56', you can change it into something like &a=12&b=34&c=56 or &ppp=12.34.56 and so on, actually any thing.+1collect search phrases and make a list like
  
-Here's an example:+word1 => synonym1 
 +word2 => synonym2 | synonym3
  
-<code>+2. add it to the sphinx
  
-subtemplate + wordforms = /path/to/your/synonyms.txt
  
-$my_var = explode('x', '<!--THUMB_LINK-->');+3. That's itthe sphinx will be able to search taking into account synonyms.
  
-in $my_var  you'll get in array like  
  
-Array +===== Related Search Queries =====  
-+
-[0] => 12 +
-[1] => 34 +
-[2] => 56 +
-)+
  
-</code>+Test version.
  
-now you can create 'your style' link +The user searches for “car” on the site, and then searches for “trailer”. Or after “auto”, it searches for “gasoline”.  
 +These are not synonyms, but we understand that these are related searches that may interest the user.
  
-an example with acb+The next time the user searches for “car”, we will not only show him “car”, but we can display “maybe you also want a trailer and gas”.
  
-<code>+Let's do it basicly using the search_query_limit feature.
  
-out.php?url=....&a=<?=$my_var[0]?>&b=<?=$my_var[1]?>&c=<?=$my_var[2]?>+1In the search template, you need to add a parameter that takes into account whether the user was looking for something before.
  
-then in common.php you have to assemble it back into a normal formatso script can understand it.+For example, the user came to the page http://domain/?search=autoin this case, if the user is again looking for something (trailer), then the URL must be formed as http://domain/?search=**trailer**&search_query_limit=**auto**.
  
-if (isset($_GET['a'])) { +This way you make it clear that “trailer” and “car” are related searches.
-$_GET['link'] = 'images/' $_GET['a'] . 'x' . $_GET['b'] . 'x' . $_GET['c']; +
-}+
  
-</code> 
  
-This way you can have any links you want.+2Display related searches (content_search)
  
 +<code>
  
 +<search_log filter=GET_search search_query_field=search_query_limit allow_dupes=true num=1-10>
 +    <!--SEARCH_QUERY--> <br>
 +</search_log>
 +
 +filter=GET_search - display search queries with the word currently searched for
 +
 +search_query_field=search_query_limit - displays “related searches” rather than the search queries themselves
 +
 +
 +</code>
  
new_rotation_hints.1396370588.txt.gz · Last modified: by admin