User Tools

Site Tools


import_replacements

Differences

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

Link to this comparison view

Next revision
Previous revision
import_replacements [2014/01/29 18:04]
127.0.0.1 external edit
import_replacements [2017/03/27 09:13] (current)
Line 8: Line 8:
  
 <​code>​ <​code>​
-xvideo has embedded ​cideos ​with width=400 ​ while we need width=500+xvideo has embedded ​videos ​with width=400 ​ while we need width=500
  
 If this field = URL If this field = URL
Line 31: Line 31:
 in This Field - URL in This Field - URL
 And Replace it With - id=30 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>​ </​code>​
  
  
import_replacements.txt · Last modified: 2017/03/27 09:13 (external edit)