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 revisionPrevious revision
import_replacements [2017/03/27 09:13] adminimport_replacements [2026/03/21 10:11] (current) – external edit 127.0.0.1
Line 1: Line 1:
 ===== Import Replacements ===== ===== 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+In Rotation Settings Import Replacementsyou can create auto-replacement rules for imported data. This is useful for automatically modifying embed sizes, URL components, or other fields during import.
  
-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: Adjusting embed size**
  
-**Example 1**+Suppose xVideo embeds have width=400, but you need width=500:
  
 <code> <code>
-xvideo has embedded videos with width=400  while we need width=500 
  
-If this field  = URL +If this field = URL 
-Contains this value = xvideo  +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) +Then Search For width=400 
-in This Field  - embed code (width=400 is located in embedded code) +in This Field - embed code 
-And Replace it With -  width=500+And Replace it With - width=500
  
 </code> </code>
  
-**Example 2**+**Example 2: Changing URL parameters**
  
-Let's say we have import like  http://somesposnor/gallery/xxxx.html?id=25, while we need  id=30.+An RSS feed provides URLs like http://somesponsor/gallery/xxxx.html?id=25, but you need id=30:
  
 <code> <code>
-If this field  = URL + 
-Contains this value = somesposnor +If this field = URL 
-Then Search For  - id=25 +Contains this value = somesponsor 
-in This Field  - URL +Then Search For - id=25 
-And Replace it With -  id=30+in This Field - URL 
 +And Replace it With - id=30
  
 </code> </code>
 +
  
 ==== EMPTY_VALUE ==== ==== EMPTY_VALUE ====
  
-Sometimes a sponsor gives just one description, while others - 2 (both for title and description)so a page may look bit truncatedб so we can copy something into an empty field +Replacements support special meta tags for conditional field operations. For SEO purposesyou often need multiple descriptions for single gallery. Instead of manually entering duplicate content, you can use meta tags to automatically copy and populate fields. 
 + 
 +Available meta tags: 
 + 
 +  <!--EMPTY_VALUE--> - the field is empty 
 +  {DESCRIPTION}, {ALT}, {URL}, etc. - gallery field variables 
 + 
 +**Example: Populate empty Title from Description**
  
 <code> <code>
-an example replacement 
  
-If this field  = Title+If this field = Title
 Contains this value = <!--EMPTY_VALUE--> Contains this value = <!--EMPTY_VALUE-->
-Then Search For  - * (* - means "everything\all"+Then Search For - * (entire field
-in This Field  - Title +in This Field - Title 
-And Replace it With -  {DESCRIPTION} +And Replace it With - {DESCRIPTION}
- +
-So if "Title" == empty then replace it with "description" +
  
 </code> </code>
 +
 +This rule copies the gallery description into any empty Title field, automatically generating a second description for SEO purposes. You can adapt this to copy to other fields like URL or custom fields as needed.
 +
 +
 +  <!--SPECIAL_CHARS_ONLY-->
 +
 +special variable to indicate that the field contains only "-,.'#? and space (so it doesn't look like a normal description)
 +
 +
 +==== ANY_VALUE ====
 +
 +Like EMPTY_VALUE, but indicates the field contains something (the opposite condition).
  
 ==== external:: ==== ==== 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.+This feature was originally designed for translations but works for any external processing of field values. You can call an external URL to modify imported data.
  
-Let's say we want to add  "!" or ".." at the end of each title+**Example: Randomly add punctuation to descriptions** 
 + 
 +Create a PHP script at http://domain.com/replace.php:
  
 <code> <code>
-So we create a script that can fo it http://domain.com/replace.php 
  
 <?php <?php
 $rand_char = (rand(0, 100) > 50) ? '!' : '..'; $rand_char = (rand(0, 100) > 50) ? '!' : '..';
-echo $_GET['phase'] . $rand_char;+echo $_GET['text'] . $rand_char; 
 +?>
  
 </code> </code>
  
-and add rule+Then add this replacement rule:
  
 <code> <code>
  
 If this field = URL If this field = URL
-Contains this value = http (all galleries) +Contains this value = http 
-Then Search For - *  +Then Search For - * (entire field) 
-in This Field  - Alt (Title) +in This Field - Alt (Title) 
-And Replace it With - external::http://domain/replace.php?phase={ALT}+And Replace it With - external::http://domain/replace.php?text={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> 
- </code>+ 
 +For each imported gallery, the script requests the URL with the actual ALT valueThe script receives the response (description with added punctuation) and saves it to the Alt field.
  
 +**Example 2: Save processed data to a different field**
  
-Here's another example just to show that you can save the result into another field+Use the same logic but save the result elsewhere:
  
 <code> <code>
  
 If this field = URL If this field = URL
-Contains this value = http  +Contains this value = http 
-Then Search For - *  +Then Search For - * (entire field) 
-in This Field  - Description +in This Field - Description 
-And Replace it With - external::http://domain/replace.php?phase={ALT} +And Replace it With - external::http://domain/replace.php?text={ALT}
  
 </code> </code>
 +
 +Now the modified text is saved to the Description field instead of Alt. This flexibility lets you transform data in unlimited ways using custom scripts on your server.
  
  
import_replacements.1490605987.txt.gz · Last modified: (external edit)