====== New Rotation Hints ====== ===== Setting GET parameters ===== This is one of the important points that you must definitely understand, because it is used in many places below. As already mentioned in [[New Rotation Templates#How it works]] all pages in new rotation are formed by essentially one script and different results are obtained depending on input parameters. Roughly speaking /scj/tube/index.php?group_name=phones will display thumbs of the phones group, and /scj/tube/index.php?group_name=cars - will display thumbs of the cars group. Although on the site it will look like /category/phones/ and /category/cars/ - clean URLs are provided by rewrites ([[New Rotation Faq#What is mod_rewrite]]) In this example /scj/tube/index.php?group_name=phones specifically group_name=phones are GET parameters. The main thing to understand in this section is: you can pass parameters to the script /scj/tube/index.php in different ways. **Option 1** Direct when you write it like this /scj/tube/index.php?group_name=phones. The only detail here is how query parameters are written: after the file name comes a ? (question mark), and parameters are separated by & (ampersand). **Option 2 - Via rewrites** For example we want to display the phones group with a specific template. In option 1 this would look like /scj/tube/index.php?group_name=phones&force_template=super_template which is not very nice. So we write a rewrite RewriteRule ^super_phones\.html$ /scj/tube/index.php?group_name=phones&force_template=super_template and the URL will be beautiful - http://yourdomain/super_phones.html. **Option 3 - via file** The rewrite option is good, but it has 2 problems: there are sites without Apache, i.e. purely on nginx for example, which doesn't read .htaccess files and accordingly the rewrites written there don't work. And if there are very many rewrites it starts to put load on the CPU. Besides, it's harder to make flexible conditions in rewrites, so there is option 3. Same task: a beautiful link for /scj/tube/index.php?group_name=phones&force_template=super_template. Create a file super_phone.php with the content and we get a beautiful URL http://yourdomain/super_phones.php Another advantage of this option is that parameters can be adjusted directly in PHP for conditions not covered by the script, for example: ===== How to sort by date by default, effectively with no homepage rotation, like a regular tube ===== * Create a main.php file on the domain root that looks like * Write the PATH (NOT URL!!!) to this file in Settings - CJPages (before this, you probably had the path to scj/tube/index.php written there - delete this line, there should be only 1 line left with the path to main.php) * That's all. ===== How to organize a trade in groups using the new rotation (rewrite) ===== First, how traffic gets from the trader to you: **The trader has a multi-niche website:** * The easiest way is to set up a redirect to the desired niche using a referrer (this is in [[Tube CMS Pages#redirects]]) * There you can also configure custom words if the names of the trader’s niches do not coincide strongly with yours **The trader has a single-niche website** * or his domain contains a niche keyword, which is a fairly common situation and he will be redirected to the desired niche anyway * or add its domain to custom niche redirects All. You don't need to do anything else for simple options. **If for some unknown reason auto-redirect does not suit you and you want the old-style with setting up each trader separately, then the options are as follows:** - create rewrite for example RewriteRule ^niche\.php$ /?niche_name=niche and ask the trader to send http://yourdomain/niche.php - option 2 is to create a file for example niche.php like and then either the trader immediately sends to http://yourdomain/niche.php or we go to the trader’s edit and set niche.php to him as a personal page. If you use any of the complex options, please describe why. We need to add an example of why this might be necessary. **Now sending traffic out by groups.** **Option 1** * Create groups for the trade, the name of the trade group must match the name of the rotation groups. In Update 45, a special button even appeared in rotation - groups, which copied the names of groups. * add rewrite. As you can see, the group is taken into account in the link to the out RewriteRule ^gal/(.*)/(.*)/index.html?(.*)$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&group=$1&url=content&slug=$3 * and change the subtemplate used to display thumbs, so that the links would be something like this a href='/gal///index.html?' It’s not difficult to notice that the group name is transmitted via rewrite. **Option 2** Update 48 introduced the Trade by groups feature We have a classic multi-niche CJ site, we want to trade in groups. To do this, you need to add &group=... to the URL, however, for tube site with rewrites this is not as convenient and beautiful as we would like. If by default the links look like /gallery/cool_gal/index.html, then to trade by group we need to do something like /gallery/current_group/cool_gal/index.html + change rewrite a little so that the group parameter is passed to the out. For those who find this difficult, there is another option. If you use default rewrite, it means that your category pages have a URL like /category/123/asian/ or simply /category/asian/, which means that if a person clicks in this category, then when out, we can determine in which category the click was made by the referrer, and depending on the category, send it to different groups of traders. To use this feature, you need to: - If you have not created them yet, then create trade groups with names as rotation categories. By the way, you can do this with one click in Rotation - Groups (Copy To Trade Groups) - Distribute traders into groups - Rotation - CMS - Tube settings enable Niche trade option - that's it :) **Option 3** Usually there are quite a few niches on a multi-niche CJ site, more than the number of niches in which I would like to distribute traders, for example, 500 niches in rotation, but I would like to distribute traders into only 15 groups. * Create groups for trade, let’s say the same 15 pieces, the names may or may not coincide with the names of the rotation groups - it doesn’t matter. * in the rotation groups, find the custom var1 field and for each rotation group, enter the name of the trade group that will be used * add rewrite. As you can see, the group is taken into account in the link to the out RewriteRule ^gal/(.*)/(.*)/index.html?(.*)$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&group=$1&url=content&slug=$2 * and change the subtemplate used to display thumbs, so that the links would be something like this a href='/gal///index.html?' ===== Thumbs' Rolling ===== Thumb rolling means taking, for example, 5 thumbs from one gallery into rotation to find the best one. You can also make thumbs roll on mouse hover within a gallery. This approach has been developed in tubes, but this has not yet happened in pix sites ([[http://demo.smartcj.com/cat/14/7%20Demo2%20%20Taylor/ctr/1/content_list_pic/image/|example for a picture gallery]], you need to hover over any thumb and wait a split second) and of course the same option [[http://demo.smartcj.com/cat/14/7%20Demo2%20%20Taylor/ctr/1/content_list_mov/movie/|for movie galleries]]. It's very easy to do: * we add JS code to the template, which arranges the roll for all pictures whose ID starts with rot * here is a role for thumb whose ID starts with 'rot'. The sub will look something like this: Rolling is based on two things: id='rot' - the script rolls only thumbs whose ID starts with rot rel="" - here the script lists all available thumbs for this gallery ===== Custom pagination ===== In mysql there are 2 options for sampling from the database: when the total number of results for a query is counted and when not. The second option is faster. Accordingly, when there is no There is still a pagination macro, but it is inside an HTML comment, so the script will still calculate , and you can use that number in your own code. You can make any one to your taste. For example $total_pages = ceil(/100); for ($i = 1; $i <= $total_pages; $i++) { echo "{$i}"; } where 100 is the number of thumbs you have on your page (you will add it, since you build the template yourself). This is a simple example, of course you can diversify it as you need for a specific page. **Option 2** In most cases, surfers don’t need the 25th page at all and people don’t go there in most cases, so it makes sense to limit them to, for example, 5 or 10 pages and just fit them into the template as is For beauty, you can select the current page, for example
  • 1 here
  • add the code and it turns out
  • 1' : '1' ?>
  • and the same for the remaining pages.
    ===== Separate page for a list of categories ===== **Option 2 First ** 1. Create a custom template, for example cat_template, in which the categories themselves are displayed, for example 2. this page will be visible via the link /scj/tube/?force_template=cat_template 3. to get a beautiful link, add rewrite RewriteRule ^categories$ /?force_template=cat_template and the page will open at the link domain.com/categories **Option 2** 1. Create a custom template, for example cat_template, in which the categories themselves are displayed, for example 2. create a file categories.php at the root of the domain in which 3. The page is available at the link domain.com/categories.php ===== Sitemap ===== By default, you have a sitemap in scj/sitemap.php, but if suddenly for some reason it’s not there, then 1. Create a sitemap template (starting from update 46 it is included in the default templates) with content like and subtemplate in accordance with the sitemap format. 2. create a sitemap.php file on the domain root Please note that if you use descriptions that contain special characters, for example & (ampersand), then you must use CDATA in the template (if you don’t know what this is, it makes sense to open Google). __Considering that this point in the docs could have been written quite a long time ago relative to the time you read it, it makes sense to check Google docs again regarding the sitemap rules.__ In addition, Google’s rules say that the sitemap size should not be more than a certain amount, so if you have more than 1-2-3k gallery, then in any case you need to divide it into pages by ?page=1 ?page=2, etc. (see [[New Rotation Hints#setting_get_paramaters]] ===== How to make RSS ===== 1. Create an rss template (starting from update 47 it is in the default templates) with content like template for rss and subtemplate in accordance with the rss format. 2. create a file rss.php on the root of the domain ===== Custom title for each template ===== For example, you include the header template in all templates, so if you want different titles for different pages, you have the following options: Option depending on template ' == 'index') { ?> This is index ' == 'content_list') { ?> This is category ' == 'content_search') { ?> this is search some other page Depending on the variables passed to the URL This is custom gallery , display gallery description here for example <!--DESCRIPTION--> This is category page, use here <!--GROUP_NAME--> This is index, any other desc here ===== How to separate content by type ===== For example, we need to display only movies on some page. To do this, you need to add content_type=movie to the parameters http://domain.com/scj/tube/?group_id=5 - all content from group 5 http://domain.com/scj/tube/?group_id=5&content_type=movie - only movies from group 5 You can also use image and flash All this also works through the file ===== Separate template for a specific category ===== Before making a separate template, think about it: maybe you don’t need a separate template, but just use custom vars for categories and thus solve this issue. However, if you are sure that you need a completely different page, then you can do it as follows: - Rotation - CMS pages - create a new template for example cat_new.tpl - in common.php we write the following (after if ($_GET['group_id'] == '1' or $_GET['group_name'] == 'group_name') $_GET['force_template'] = 'cat_new'; where 1 and group_name are the corresponding ID and name of the category you need ===== Blog on a subdomain ===== - Create a subdomain, copy common.php, index.php, as well as 2 directories scj/cgi and scj/tube to the root + create .htaccess as usual - In the basic admin panel we create templates, for example blog_index, blog_content_list, etc. - We got 3 komons, so as not to get confused, we’ll do the same in all 3 After ===== Skimming on custom galleries ===== In version 46, a new option has been added - skimming to gallery. Rotation - CMS - Tube Settings can be set **custom gallery skimming** for example in the form 100%,70%trader.com,70%sponsor,50%sponsor_join,100 first click on the content (100 and 100% are the same, you can write it as you wish) second: 70% content, rest acc. 30% - /scj/cgi/out.php?member=trader.com, 3rd: 70% content 30% sponsor (on the URL that is registered with the sponsor in the site url) 4th: 50% content 50% sponsor (URL - join url), 5 and onwards - 100% content Please note that this only works if you link not directly to the content, but through a script, for example ===== Niche traffic selling ===== Many people sell traffic on exchanges. When purchasing, the exchange only takes into account the domain and for multi-niche domains the price of traffic is usually lower than for niche ones, however, it is possible to send traffic indicating a niche and in this case the exchange can give a higher bid. For example, usually everyone sells traffic using the link http://brocker.com/in.cgi?your_id In this case, if you have a multi-niche, your traffic is considered multi-niche traffic. But the exchange provides the opportunity to send traffic like http://brocker.com/in.cgi?your_id&niche=test, where test is a niche. Such traffic is already considered niche and may cost more. To do this, we add the {GROUP} parameter to the sales URL; the URL looks like http://brocker.com/?id=your_id&niche={GROUP} (for example, for the holder http://www.trafficholder.com/in/in.php?yourid-{GROUP}). However, the question is that the broker does not have a Japanese niche? the closest one is for example tube_asian. To do this, in Rotation - CMS - Tube settings there is a Niche traffic sell field in which we need to enter the correspondence between our niches and the broker’s niches, for example, tube_asian=Japanese,Asian where tube_asian is the broker’s niche, and Japanese,Asian are our niches on the site, separated by a comma. ===== PHP in navigation ===== As you know, you can use PHP in template. And of course, it can be used in navigation to display, for example, some category in a different color, or somehow highlight it, or not display a category, etc. by default it looks something like this Let's say we need to highlight the girls category with color ' == 'girls') { ?> Let's say we need to skip the girls category in this list ' != 'girls') { ?> ===== Extra Thumb ===== For design, it is sometimes convenient to have 2 sizes of thumb rotation, for example, to show large thumbs on the index, and smaller ones on category pages. To make the script create larger images for the index, create a crop profile with larger dimensions in Rotation - Settings - Crop Profile, and specify that profile in the Extra Thumb field during grabbing. In that case the script creates two thumbs: one regular thumb, for example /scj/thumbs/123/456.jpg, and a second one from the same source using the other crop profile, for example /scj/thumbs/123/456.jpg.extra.jpg You can use this in a template like this: usually we display thumb as If you made an extra thumb, then you can display it as follows: ===== How to make a personal template for a trader in the new rotation ===== - Create a template in Rotation - CMS pages, for example trd_tpl - Create a file for example trd_tpl.php at the root of the domain with the following content and write the PATH (!NOT URL!!!) to this file in the trader edit. ===== How to remove the rotation parameter from links (1x23x456) ===== Relevant only for script version 1.x In version 2.x there is a magic rotation parameter, when nothing is needed in the links Typically links look like this: /gallery/cool_gallery/index.html?12x34x56 12x34x56 are rotation parameters, the goal is to get rid of this in the URL so that it looks more aesthetically pleasing. You can do it like this: 1. In the sub, your links look something like this: replace with no matter how difficult it is to notice, we put in the rot_id parameter 2. add to ===== I don't like links like /gallery/cool/index.html?123x45x678 ===== There are 2 types of “dislikes” here - the /gallery view itself, etc. - this changes in rewrite. 2nd option - I don’t like that 123x45x678 is right after the URL, it changes there, etc. Here are the options: 1. If you don’t like that the surfer sees it - http://smartcj.com/wiki/doku.php?id=new_rotation_hints#%D0%BA%D0%B0%D0%BA_%D1%83%D0%B1%D1%80%D0%B0%D1%82%D1%8C_%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80_%D1%80%D0%BE%D1%82%D0%B0%D1%86%D0%B8%D0%B8_%D0%B8%D0%B7_%D0%BB%D0%B8%D0%BD%D0%BA%D0%BE%D0%B2_1x23x456 2. For CE - http://smartcj.com/wiki/doku.php?id=custom_galleries_and_google 3. For CE there is also another option - to make links like /gallery/cool/index.html?link=images/123x45x678 and in GWT declare that link is an insignificant parameter and Google can ignore it. To do this, in .htaccess we replace places like out.php?link=images/%{QUERY_STRING} on out.php?%{QUERY_STRING} In the template we change it to http://domain/gallery//index.html?link=images/ **Option 2 of changing the end of links** In rewrite we change RewriteCond %{QUERY_STRING} ^(.+)$ RewriteRule ^gallery/([^/]+)/index.html$ /scj/cgi/out.php?link=images/%{QUERY_STRING}&url=content&slug=$1 [L] on RewriteCond %{QUERY_STRING} ^param=(.+)$ RewriteRule ^gallery/([^/]+)/index.html$ /scj/cgi/out.php?link=images/%1&url=content&slug=$1 [L] As you can see, param has been added here, which can be disabled in GWT Accordingly, links should be made like href="/gallery//index.html?param= **Option 3 if you want a completely different look** At the moment, the tag produces conditionally 12x34x56, for example, you want it to be &a=12&b=34&c=56 or for example &ppp=12.34.56, etc., in a word, some other type. you do it in saba $my_var = explode('x', ''); you get an array Array ( [0] => 12 [1] => 34 [2] => 56 ) and you can form a link from it as you wish for example option with a b c out.php?url=....&a=&b=&c= and in common.php the parameter is added back if (isset($_GET['a'])) { $_GET['link'] = 'images/' . $_GET['a'] . 'x' . $_GET['b'] . 'x' . $_GET['c']; } In this way, you can make parameters with any names or dots; in a word, your imagination is not limited in any way. ===== How to display all pages in navigation ===== Typically navigation (aka pagination) looks something like this: 1 2 3 ... 40 41 42. If you need to display all 42 without... you need to replace the navigation with something like the following Was
  • replace it with ///" title=""> --> /$thumbs_per_page); for ($i = 1; $i <= $total_pages; $i++ ) { ?>
  • where $thumbs_per_page = 200; accordingly, the number of thumbs per page in your template.
    ===== Rating ===== To add a custom gallery rating you need (using the example of content_custom_pic) Add styles to make the stars beautiful Add a JS script that will beautifully do mouseover for stars We add the stars themselves

    Rate this movie:

    > 0) echo 'checked' ?> > > 1) echo 'checked' ?> > > 2) echo 'checked' ?> > > 3) echo 'checked' ?> > > 4) echo 'checked' ?> >
    All. PS You can display the rating anywhere with the tag - this will be a number from which you can get anything. the simplest example in the sub > 0) echo '*' ?> > 1) echo '*' ?> > 2) echo '*' ?> > 3) echo '*' ?> > 4) echo '*' ?> ===== Rating +1\-1 like\dislike ===== And other 2-variant ratings. The idea is simple: reduce the rating scale to two values, 1 and 2. In practice, 1 means dislike and 2 means like. So an average of 1.5 means a 50/50 split between likes and dislikes, while 1.75 means 75% like and 25% dislike. Technical implementation: Add a JS script that will post the voting result THIS IS ONLY NEEDED 1 TIME, IF YOU ALREADY HAVE IT IN THE TEMPLATE THEN YOU DO NOT NEED TO INSERT IT A 2ND TIME Adding voting buttons and rating output
    current rating = == 0) ? 'not rated' : round( ( - 1) * 100 ) . '%'?>
    rate it: +1 ............................ -1
    +1 and -1 are replaced with fingers, checkmarks, etc.
    All. ===== PHP code in template ===== As you probably know, you can use PHP code in templates. Of course, it will not be possible to consider all the nuances of the language in one example, and apparently it is not necessary, but I would like to show a small example. For example, we need to display the desk tag and we decided to make it all in capital letters, in PHP it’s very simple: change to ')?> However, there is one important caveat: if the description contains a quote, you will get something like , which breaks the string and causes a PHP error. For that reason, 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]] An example with would look like: ')?> ===== Comments ===== It's just as easy to add comments. Add code that will post a comment without reloading the page (AJAX) ---- this line is not required if jquery is already included somewhere, for example in the rating. Adding an HTML comment form

    Add comment

    Visual CAPTCHA
    and add the output of existing comments : All. ===== Geo targeting ===== In fact, this is an example of PHP code in templates banner code 1 banner code 2 ===== Two indexes with different content types ===== Suppose you need two pages, one for movie content and one for image content. For example: movies.php and images.php Option 2 1. We do everything on one template * create 2 files of the form * we register any of these pages in CJ Pages - this will be the site index * since template is not specified here, index will be used * if in your design you somehow work differently with different sizes of movie and picture thumbs, then for processing use code like this text 1 testct 2 Option 2. We make 2 different templates, for example index_movies and index_images with the desired design and navigation, as well as 2 view files ===== Translation of the site menu (i18) ===== It’s quite easy to translate the site menu (those links like Most Popular, Order By date, etc.) into other languages. Rotation - CMS Templates - Tpl Custom Var add custom variables, for example most_popular, this variable can be used in templates like , and you can set a separate translation for each language. ===== Another flash player ===== By default in the script there is a free player Jwplayer, at the moment it is already a bit old player, but it works :) If you want any other player, then the main thing is that you need to understand that the player and the script are not connected in any way. The script generates an HTML page where it replaces tags and how the page is displayed depends on the browser. How the movie plays depends on the player. By default the code is as follows As you can see, the player /scj/tube/player/player.swf is called and the parameters flashvars="file=&image=" are passed to it. You can put your player anywhere convenient, any player, change the template so that it loads your player, just check how it needs to pass parameters. For example, Kernel player ===== How to quickly create a blog using an existing database ===== If you filled the database well initially and you have good descriptions and a custom gallery is highly desirable, then you can create a parallel blog for the site in 10 minutes. * create a subdomain conditionally blog.yourdomain.com * set this to the smartcj subdomain * make it slave yourdomain.com * download [[http://smartcj.com/wiki/local_upload/SCJ_templates.example.49.sql|blog templates ]] * upload this file to Rotation - CMS (at the bottom Upload Templates) That's it, the blog is ready :) ===== Suggestions Based on logged searches ===== Auto-suggestions when the user starts to enter a search based on what was previously searched This may already be on the page. This script does the autocompletion some styles for beauty the search field itself
    The template 'search_suggest' itself { "query":"", "suggestions":[ {"value":"","data":""} ,{"value":"","data":""} ]} How to check: /scj/tube/index.php?force_template=search_suggest&zero_items_to_404=off&query=... should produce results with those searches that are already in the database ===== Suggestions : Based on regular search ===== The same as above, but it suggests not by the search database, but by the gallery database styles a field
    JS code template 'gallery_search_suggest' { "query":"", "suggestions":[ {"value":"","data":""} ,{"value":"","data":"/gallery//index.html"} ]} As you can see, the only difference is that in the template itself, specifically in the


    As it’s not difficult to notice, there is no flash player and all thumbs point to /scj/tube/?slug=&force_template=content_flv_single_item&item_id=... where there is another template **content_flv_single_item** where the flash player will be, as well as item_id - where the number of the movie from the gallery is transmitted, which should be played. **Content content_flv_single_item**
    there are 3 almost identical pieces that differ only **2. Grabbed gallery** When grabbing content or later through editing, you need to set **Embed Template** for this gallery, respectively - content_flv_gallery **3. rewrite** URLs like /scj/tube/?slug=&force_template=content_flv_single_item&item_id=1 don’t look particularly nice, so you can add rewrite for example RewriteRule ^flash_gallery/([^/]+)/([0-9]{1,2}).html$ /scj/tube/?slug=$1&force_template=content_flv_single_item&item_id=$2&%{QUERY_STRING} [L] and accordingly replace content_flv_gallery in the template links like on **4. Features of this gallery** Her sponsor posted 2 types of links to content: they are flash, others are in the form of links to movie clips for scripts that do not know how to rob flash content. This is correct, but the script will download both options, although we only want to output flash. For us, this is only bad because some of the content that we don’t need will be stored on disk. Accordingly, when adding content, you can set Add only this type of content - flash in the import. This will save some disk space. ===== Navigation within one gallery ===== For example, we have a custom pix gallery with a certain number of images. Clicking on thumb opens not the picture itself, but a page with this picture plus some additional advertising, etc. You can put links on the same page to the following images of this gallery, for example .html'> Prev ) { ?> .html'> Next If you have other rewrites, do not forget to edit the links. ===== Friendly tube ===== For content sites on the same base (master slave), there is an option to organize a trader among themselves, when the surfer sees the content but on another site in the network. For example, a user clicks on http://domain1.com/gallery/gallery_slug/index.html, but the skim script decides to send him for a trade. In this case, the user does not see the gallery. If we send it to another site in our network, we can show it the gallery, but on a different domain. This has a positive effect on the product of the original site (the person wanted to see the movie - he saw it), and also makes it possible to show other thumbs around the embed itself = the surfer can click on these thumbs on the trader’s site. To do this, on the domain1.com website for the domain2.com trader, specify the site type - Friendly Tube. In this case, if the script decides to send to this trader, then the script will send the slug gallery to the trader. Of course, only if the redirect to the trader occurred when they clicked on the content, and not in the toplist. The script will simply send those to http://domain2.com/ and add http://domain2.com/?try&slug=super_gallery. to the URL On domain2.com, if of course SmartCJ is also installed there, the script sees this slug and does not open the site index, but redirects to the URL Try Param Redirect URL, which looks something like http://{DOMAIN}/gallery/{GET_slug}/index.html those redirect to gallery. If you have your own rewrites, then you need to change the URL to match your rewrites. This is of course only relevant when - if the trader also has SmartCJ - if you use either master-slave (then the IDs are 100% the same) or if the content as a whole overlaps. If there is no gallery with this ID on the trader’s website, it will just be an index ===== Custom links ===== Links to gallery in the default version /gallery/gallary_slug/index.html in order to change them you need to change rewrite + template so that the URLs for your rewrite are generated. Likewise for categories, tags, etc. The only special case here is category links such as /category/cool/date/1/. The word cool is the category name, but date is already a sort key, and the script must receive a sort value it understands. If you put something like new_galleries_first there, the script will not know how to interpret it. To change to this option you need to: Add to common.php (note: they should all be the same) if (isset($_GET['order']) and $_GET['order'] == 'new_galleries_first') { $_GET['order'] = 'date'; } elseif (isset($_GET['order']) and $_GET['order'] == 'long_galleries_first') { $_GET['order'] = 'duration'; } else { $_GET['order'] = 'ctr'; } Now the /category/cool/new_galleries_first/1/ option will work as expected. However, in the navigation itself there is SORT_ORDER, which is actually equal to $_GET['order'], and we need our option. Therefore, we also add our own variable to common.php if (isset($_GET['order']) and $_GET['order'] == 'new_galleries_first') { $_GET['order'] = 'date'; $GLOBALS['original_sort_name'] = 'new_galleries_first'; } elseif (isset($_GET['order']) and $_GET['order'] == 'long_galleries_first') { $_GET['order'] = 'duration'; $GLOBALS['original_sort_name'] = 'long_galleries_first'; } else { $_GET['order'] = 'ctr'; $GLOBALS['original_sort_name'] = 'best_galleries_first'; } And in the template, instead of SORT_ORDER, we use PS In the navigation tag you need to add skip_href_deletion=true so that it does not clean up your PHP code. ===== Random keywords for galleries ===== If you have a list of keywords that you would like to randomly scatter throughout the gallery (for example, create a custom var and then use it somewhere in the gallery), then you can do it like this: * create a text file with keywords (conditionally keywords.txt) * PHP script kw.php * make sure that in the browser http://domain/kw.php displays a random string * add import replacement of the form If this field = URL Contains this value = http Then Search For = * in This Field = Custom field 1 And Replace it With = external:http://domain/kw.php All. The main thing here is external:http://domain/kw.php, those custom var will receive the value that will be given by external:http://domain/kw.php. ===== Site with main niches ===== Let's say we need to create a website with 3 main niches and X additional ones. Main niches: general (id 1), guy (2) and bumblebee (3) and for example 100 niches like teen (id 4), amateur (id 5) and so on It is logical that if a person wants to see general, but most likely he does not want to see the rest 2 and 3. Those in categories 1, 2 and 3 should have global filtering. Thus, all galleries on our site end up in at least 2 categories: one of 1 2 3 and at least one of the others (in our example, 4 and 5). When outputting gallery, we can limit what the surfer wants to see. For example, he wants to see type (4) and only general (you need to exclude groups 2 and 3) - the link is obtained /?group_id=4&skip_group_id=2,3 If you need to see a teen, but which is a guy in the group (this means you need to exclude 1 and 3), then the link will be /?group_id=4&skip_group_id=1,3 Using the same scheme, you can divide, for example, tags /?tag=...&skip_group_id=1,3 **thumb categories:** Settings - System Thumbs you can configure the required number of thumb categories. In this case, we need 3 sets (sets) of thumb categories - for each of groups 1 2 and 3. In order to filter thumb categories there is a field Skip group ids, comma separated For example, for category 1, in which we do not want to see the thumb from the categories guy and shemale, we should write 2,3. Set 2 we will have a guy, then we will exclude the groups general (1) and bumblebee (3), we will write 1.3 there. When displaying thumb categories, we can specify which set to display, for example, we will display set 2 , and in the movie player something like file: /scj/thumbs/galleries/.../1.flv And the surfer sees a direct link to /scj/thumbs/galleries/.../1.flv and can download the movie. For example, we decided to make the user’s life a little harder and prevent him from downloading via a direct link. How to do this (assuming we have nginx): 1. first, in the nginx config, disable downloading files directly location ~* /scj/thumbs/galleries/.*\.(flv)$ { deny all; } and add a secret location there too location /protected { root /var/www; internal; } 2. Let's tweak the template a little. For example now it looks something like this which gives us approximately the following result we will add /content.php?check=&url= and the result will be 3. create content.php In total, if you configured nginx correctly, then when you directly request /scj/thumbs/galleries/482/850/0_771.flv it should display 403. The link /content.php?check=1511450638&url=/scj/thumbs/galleries/482/850/0_771.flv should give the file, here 1511450638 is just unix time. It can be replaced with anything. ===== Content when no content is found ===== For example, a person was looking for some keyword that you don’t have on your site, and he was given 0 search results. But you would like to show at least something. There are 3 options: **First** By default, if nothing is found, it shows template content_not_found , but if you display it there then these will be your random gallery **Option 2** if you don’t want to change content_not_found then make a separate random_content template Nothing found , look at those links .... and change the search template (content_search) as == 0) { ?> display thumb as usual in search Nothing extra is added to this soup. **Option 3** Just change content_search like == 0) { ?> Nothing found , look at those links .... .... display thumb as usual in search This option is simpler, but the downside is that even if something is found, the tag will be processed (php is reflected after the script macros) and this means a little more load. ===== Last Visited Galleries ===== This is an example of using cache in template and macros Add the following piece of code to the gallery template (for example content_page) Current gallery id:


    ') { $last_items = Cache::get('last_items'); if (!$last_items) $last_items = array(); if ($last_items[0] != (int) '') array_unshift($last_items, (int) ''); $last_items = array_slice($last_items, 0, 100, true); Cache::set('last_items', $last_items, 3600); } ?> Last visited:
    Here you should note for yourself - Cache::set('last_items', $last_items - add viewed IDs to cache - in the tag we display it, picking it up from cache - added to the list of recently viewed only if there is one if ('') { - but the list itself can also be displayed on the index Here you need to understand that - if you open a page without cache, then the list of recent ones will not be read (no cache) - the cache page along with this list, if you looked at gallery ID 1 2 and 3, then for 3 in the last viewed there will be 1 and 2, but for 2, even if you open it again after 3, only 1 gallery 2 will be cached. There are 2 options here: - leave it as it is because for a surfer it’s not so important - reduce cache time (cache_time=100) ===== Last Visited Galleries by Country ===== Here we need a slightly deeper understanding of the process. You have a website page, so you don’t have to generate it for each surfer - it is generated and stored in cache for some time, so you don’t have to generate a new page for the next visitors. If we want to show as in the example above, but by country, we need to at least remake the page for each country, given that there are 190 countries in the world, which means we will need to generate 190 times more pages (for each country separately) To avoid this, you can go another way - for example, on the index we make a code that conditionally requests the last_viewed.php page and displays the content - it turns out that the index will be the same for everyone and only last_viewed.php will need to be worked out 190 (according to the number of countries) How to do it step by step 1. add gallery to the template id: ') { $cache_id = 'last_items_' . $_SERVER['GEOIP_COUNTRY_CODE']; $last_items = Cache::get($cache_id); $last_items[(int) ''] = (int) ''; $last_items = array_slice($last_items, 0, 100); Cache::set($cache_id, $last_items, 86400); } ?> here in the cache variable $cache_id = 'last_items_' . $_SERVER['GEOIP_COUNTRY_CODE']; the gallery list is added (last 100). As you can see, the variable depends on the country. 2. create a new template viewed_in_country ......
    Pay attention to gallery_id=CACHE_GET_last_viewed_cache_id. This means the gallery_id list is taken from CACHE using the GET variable last_viewed_cache_id. 3. where you need to display a gallery list for the current country last viewed in
    the main thing here is that we are requesting a URL ./?force_template=viewed_in_country&last_viewed_cache_id=last_items_ where in the last_viewed_cache_id variable we pass from which cache id the gallery list should be taken, and this variable will be different for each country. the resulting content is inserted into div = last_viewed Total needed for the test * go to a couple of gallery for step 1 to work * open in the browser ./?force_template=viewed_in_country&last_viewed_cache_id=last_items_US , here US is your country code - should display a list of gallery IDs where you were in the previous paragraph ===== Master/Slave First Thumb ===== The master and slave have the same gallery set since it is one database. This means we can arrange a trade between sites on the same base in such a way that when going to the trader, the first thumb matches the one on which the click was made. This should boost sales. How to set it up: a simple version for clarity 1. on site A, surfer click on gallery 12345, when going to the trader (site B), we need to let site B know which gallery to show first (id 12345). To do this, the out parameters must contain the ID of the gallery on which the click is made, for example click
    As you can see here, the show_gallery_id= parameter is passed to out, the URLs will be like out.php?show_gallery_id=12345 2. On site A, change the URL of the trader (site B) (only those that are on the same database and will support this feature) http://trader/?first_gallery_id={GET_show_gallery_id} Note the {GET_show_gallery_id} placeholder from step 1. When sending traffic to the trader, it is replaced with the value that was passed to out, so the trader receives a URL like http://trader/?first_gallery_id=12345 3. add an index to the trader’s template first gallery
    here you should note gallery_id=GET_first_gallery_id which is taken from point 2 All. ===== Rotate for Rows ===== There is a useful rotation option Rotate page for raws ie if surfer visits us for a second time - show him second page instead of the first one If a surfer goes to the site’s index, then we can automatically change the &page= parameter, those on the first visit the user actually sees &page=1, on the second (when the user is no longer unique) &page=2 - those if your index displays just thumb then on the first login the user will see thumb 1-10, on the 2nd thumb number 11 - 20. **If you have thumb categories on your index** then the situation is different and there are 2 options 1. if, for example, you have only 100 categories, and you display 50 on the index
    Pay attention to set_id=GET_page. The script will then rotate three different sets of thumb categories. ===== Custom Vars for Ads ===== If the same ad insertion code is used then I often see something like 1. create an ads template in which $ads = ' The problem is - the code is not cached and PHP is executed every time (such simple code does not add much load, but still) - if you need to change advertising, you need to go to websites and edit the template, which is not very convenient - the client can edit to something like $ads = 'Today's Deal!' '; , get a PHP error due to incorrect quotes If you use Rotation - CMS -TPL Custom var then you can - get variables for template in the form of tags that are cached - There you can edit these custom tags on the entire network at once. Moreover, both all at once and individual tags. - no problems with quotes ===== Related From Another Domain ===== You can add traffic for your new domains if, for example, you include a link to gallery on your domains with traffic, for example * you have a domain And where there is a lot of traffic * there is a new domain B * on domain B we make a template like
    * and display the template on domain A for example like this Thus, on domain A there will be links directly to gallery from domain B, plus thumb from domain B will begin to receive CTR. ===== Sphinx Related Search ===== Advanced search with synonyms. For example, a user searches for “car”, but in our database it says “auto”, because the descriptions do not match - they will not be found. Sphinx has synonyms that solve this problem. 1. collect search phrases and make a list like word1 => synonym1 word2 => synonym2 | synonym3 2. add it to the sphinx wordforms = /path/to/your/synonyms.txt 3. That's it, the sphinx will be able to search taking into account synonyms. ===== Related Search Queries ===== Test version. The user searches for “car” on the site, and then searches for “trailer”. Or after “auto”, it searches for “gasoline”. These are not synonyms, but we understand that these are related searches that may interest the user. The next time the user searches for “car”, we will not only show him “car”, but we can display “maybe you also want a trailer and gas”. Let's do it basicly using the search_query_limit feature. 1. In the search template, you need to add a parameter that takes into account whether the user was looking for something before. For example, the user came to the page http://domain/?search=auto, in this case, if the user is again looking for something (trailer), then the URL must be formed as http://domain/?search=**trailer**&search_query_limit=**auto**. This way you make it clear that “trailer” and “car” are related searches. 2. Display related searches (content_search)
    filter=GET_search - display search queries with the word currently searched for search_query_field=search_query_limit - displays “related searches” rather than the search queries themselves