Note that there are some explanatory texts on larger screens.

plurals
  1. POfull interface translation with wysiwyg editor
    primarykey
    data
    text
    <p>i need to provide the site administrator with a way to translate the site interface. all the text in the buttons and titles and labels should be editable, and when a new language is added he will be able to enter a new translation for them.</p> <p>for that purpose i want to use a wysiwyg editor. i have some experience with thous editors so i have no technical problems making it work. my problem is this :</p> <p>when i edit html with wysiwyg editor i then submit the changes to server via ajax request for storage (in a db). in order to identify the content that is submitted, and relate it to a certain table/row, i use a unique identifier, for example <code>table_name+row_id</code>. this identifier is written in to the html and then used when submitting the content</p> <p>when the content is originated in the db and have <code>table_name+row_id</code> there is no problem, but how can i edit the interface, all the static html elements that don't have this uid. </p> <p>first of all i moved all the static text to the db, but the problem is that all this content is originated in the html file so i don't have any way to id it and tie it to the db row that needs to be edited</p> <p>now i use hand written unique ids in the html, but this require to much time and effort. <strong>i need a better way to do this</strong>, and i was not able to find anything online</p> <p>here is how it works now:</p> <p>html file :</p> <pre><code>&lt;h1 id="page_title"&gt; &lt;?=get_text('51920ae518647','This is a page title')?&gt; &lt;/h1&gt; </code></pre> <p>*the <code>$uniq_id</code> parameter is hand written in the html</p> <p>server side :</p> <pre><code>function get_text($uniq_id, $default){ $return_text = ""; if (!empty($page['data']['html_text']['by_uniq_id'][$uniq_id])){ $return_text = $page['data']['html_text']['by_uniq_id'][$uniq_id]-&gt;text; } else{// insert the default value to the db $text = new html_text($uniq_id, $default); if ($text-&gt;save()){ $page['data']['html_text']['by_uniq_id'][$uniq_id] = $text; $return_text = $default; } else{ error_log("Get html text error : new text save failed"); } } if ($is_admin) return '&lt;span class="editable_content" id="' . $uniq_id . '"&gt;' . $return_text . '&lt;/span&gt;'; else return $return_text; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload