User Tools

Site Tools


import_replacements

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
import_replacements [2017/03/27 09:13]
admin
import_replacements [2017/03/27 09:13] (current)
Line 1: Line 1:
 +===== Import Replacements =====
 +
 +Rotation - Settings - Import Replacements you can add autoreplacements that will be used always when you import something, that means both Import and ImportSets and even TubeImport. 
 +
 +This is very useful to remove\replace some text in import, for example size of embedded video or some text in gallery description.
 +
 +**Example 1**
 +
 +<code>
 +xvideo has embedded videos with width=400  while we need width=500
 +
 +If this field = URL
 +Contains this value = xvideo 
 +
 +ie this rules works only if we have 'xvideo' in URL 
 +
 +Then Search For  width=400 (what we have in original format)
 +in This Field - embed code (width=400 is located in embedded code)
 +And Replace it With - width=500
 +
 +</code>
 +
 +**Example 2**
 +
 +Let's say we have import like  http://somesposnor/gallery/xxxx.html?id=25, while we need  id=30.
 +
 +<code>
 +If this field = URL
 +Contains this value = somesposnor
 +Then Search For  - id=25
 +in This Field - URL
 +And Replace it With - id=30
 +
 +</code>
 +
 +==== EMPTY_VALUE ====
 +
 +Sometimes a sponsor gives just one description, while others - 2 (both for title and description), so a page may look a bit truncatedб so we can copy something into an empty field 
 +
 +<code>
 +an example replacement
 +
 +If this field = Title
 +Contains this value = <!--EMPTY_VALUE-->
 +Then Search For  - * (* - means "everything\all")
 +in This Field - Title
 +And Replace it With - {DESCRIPTION}
 +
 +So if "Title" == empty then replace it with "description" 
 +
 +</code>
 +
 +==== external:: ====
 +
 +The main purpose of this replacement is to translate texts but you can use it in any other way, for example to replace something that was not provided by the script.
 +
 +Let's say we want to add  "!" or ".." at the end of each title
 +
 +<code>
 +So we create a script that can fo it http://domain.com/replace.php
 +
 +<?php
 +$rand_char = (rand(0, 100) > 50) ? '!' : '..';
 +echo $_GET['phase'] . $rand_char;
 +
 +</code>
 +
 +and add a rule
 +
 +<code>
 +
 +If this field = URL
 +Contains this value = http (all galleries)
 +Then Search For - * 
 +in This Field - Alt (Title)
 +And Replace it With - external::http://domain/replace.php?phase={ALT}
 +
 +That means that for each imported gallery we will request http://domain/replace.php?phase={ALT} where {ALT} is an actual alt(title) for this gallery and replace.php will return a new value (with ! or .. at the end), and the script will save it this way into DB
 + </code>
 +
 +
 +Here's another example just to show that you can save the result into another field
 +
 +<code>
 +
 +If this field = URL
 +Contains this value = http 
 +Then Search For - * 
 +in This Field - Description
 +And Replace it With - external::http://domain/replace.php?phase={ALT}
 +
 +
 +</code>
 +