Skip to content

Instantly share code, notes, and snippets.

@SergeyMiracle
Created August 15, 2014 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SergeyMiracle/2818ce97c15eef41d00e to your computer and use it in GitHub Desktop.
Save SergeyMiracle/2818ce97c15eef41d00e to your computer and use it in GitHub Desktop.
Custom settings plugin for modx evo
$e = &$modx->Event;
$output = "";
if ($e->name == 'OnSiteSettingsRender'){
$settingsArr = !empty($settings) ? explode('||',$settings) : array('Example custom setting~custom_st_example');
$fname = !empty($pname) ? $pname : 'Инфо сайта';
$output .= '</td></tr></table></div><div style="display: block;" class="tab-page" id="tabPage8"><h2 class="tab">'.$fname.'</h2><script type="text/javascript">tpSettings.addTabPage( document.getElementById( "tabPage8" ) );</script><table border="0" cellpadding="3" cellspacing="0"><tbody>';
foreach($settingsArr as $key => $st_row){
$st_label_arr = explode('~',$st_row);
$custom_st_label = trim($st_label_arr[0]);
$custom_st_name = isset($st_label_arr[1]) ? $st_label_arr[1] : 'custom_st';
$custom_st_value = isset($st_label_arr[1]) && isset($modx->config[$st_label_arr[1]]) ? trim($modx->config[$st_label_arr[1]]) : '';
$output .= '<tr><td class="warning" nowrap="">'.$custom_st_label.'</td>
<td><input type="text" value="'.$custom_st_value.'" name="'.$custom_st_name.'" style="width: 350px;" onchange="documentDirty=true;" /></td><td>[('.$custom_st_name.')]</td></tr><tr><td colspan="2"><div class="split"/></td></tr>';
}
$output .= '</tbody></table>';
}
$e->output($output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment