How to make Custom autocomplete in Atom? - atom-editor

how can we create custom snippet for PHP-Language in atom?
example:
if i write class then it shows my custom snippet.

Make a snippet in your snippets file!
First, open your snippets file. I use cmd-shift-p to search all actions and then type snippets and then select Application: Open Your Snippets to open the snippets file. Then you can use the snip snippet to create a new snippet! For example:
'.text.html.php':
'Class':
'prefix': 'class'
'body': 'Your template'
Atom uses the cson format for the snippets and other editor files. (CSON is CoffeeScript JSON)

Related

How to display a dynamic html table generated in an external script in wordpress?

In Admin/Dashboard/pages myPage/edit
[insert_php] include('path/to/external/script.php'); [/insert_php]
Inside script.php, I build a html table: $tbl.
How can I echo the $tbl on myPage?
Note: In the end of the script if I test the content of $tbl by typing die(var_dump($tbl))), I get the correct html string.
You can create a custom page template (see http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-page-in-wordpress how it works) and then add your PHP snippet to this template.

How to add "code" format button to Tinymce 4 in WordPress 3.9

Tinymce offers an inline code formatting option that wraps the <code> tag around content. But WordPress does not include this. I think that there must be an easy way to enable it. I have seen discussing on how to do this in earlier versions of WP (with Tinymce 3) in threads like Add "code" button to wordpress tinyMCE ,
but I can't see how to "translate" this into Tinymce 4.
I tried the following. It gives me the Source Code but not the code tag.
// Add <code> support to the Visual Editor
// Load the code TinyMCE plugin
function my_TinyMCEplugins($plugin_array) {
$plugin_array['code'] = get_bloginfo('template_directory') . '/inc/code/plugin.min.js';
return $plugin_array;
}
add_filter('mce_external_plugins', 'my_TinyMCEplugins');
// Add the code button into the toolbar
function my_TinyMCE($in) {
$in['toolbar2'].=',code';
return $in;
}
add_filter('tiny_mce_before_init', 'my_TinyMCE' );
Thanks for any help!
Actually the TinyMCE code plugin is NOT used to insert <code> tags. It is used to edit the source html code, which is redundant in wordpress since you can just click the 'text' tab.
This wordpress plugin will add that functionality for you: https://wordpress.org/plugins/tinymce-code-button/screenshots/.

hook_preprocess_page() does not seem to use the suggested template file

I am suggesting a template file in the hook_preprocess_page() implementation done from a module, but the suggested template file doesn't seem to be used.
The template file is page--terminal-template.tpl.php, which is in the directory containing the module, and this is the implementation of hook_preprocess_page().
function terminal_preprocess_page(&$variables) {
if (arg(0) == "terminal") {
$variables['theme_hook_suggestions'][] = "page__terminal_template";
}
}
Could anyone please help me?
Preprocess and process functions can be implemented by modules. In fact, the documentation for theme() lists them when it shows in which order those functions are called.
The fact is that Drupal looks for the suggested template files in the theme directory. You have these alternatives:
Put the template files your module is suggesting in the directory containing the theme currently used
Follow what reported in Load view template on module activation to load the template files from the module directory
Suggest the template files you want to use in a preprocess function implemented by a theme
Following what reported in the other question, you would be able to use the template file found in the module directory. The only problem is that you would be using a generic template that could be different from the default page template used from the currently enabled theme.
If you are adding template files for the currently enabled theme, you should call drupal_theme_rebuild() to make Drupal rescan the directory containing the template files, after you added the new template file to the theme.
Actually, this hook can also be called from theme's template.php file along with module's hook.
Please refer Drupal 7 documentation here.
Say if your active theme is MY_THEME, then the code should be:
function MY_THEME_preprocess_page(&$variables) {
if (arg(0) == "terminal") {
$variables['theme_hook_suggestions'][] = "page__terminal_template";
}
}
And the template suggestions will work.
Edit: This functionality can also be implemented with Modules using hooks.

How to add to the "New from Template" list?

I have added a new file template to Aptana Studio 3.0.4 as described in this documentation section:
http://wiki.appcelerator.org/display/tis/Creating+a+new+template
The new template now shows up when I select File->New->File and enter an appropriate filename. So far so good.
Now I'd like my new template to show up in the File->New From Template listing. I have not been able to locate any documentation that explains how to do this.
Ok this is actually fairly simple. For my example I will be creating an alternative php file template with a html5 structure.
On the main menu click: Command->PHP->Edit this bundle. You should see a folder named "PHP" appear in your Project Explorer window.
Open the project by double clicking on it and open the folder templates. Inside I see two files: template.php and template.rb
Create the file type you want to add here and name it phpHTML5.php.
Open the newly created file and paste (or create) your template inside and save.
In the same folder open template.rb
Printed at the bottom of the file is the structure:
template "PHP Template" do |t|
t.filetype = "*.php"
t.location = "templates/template.php"
end
Copy and paste it below changing the template to phpHTML5 the following changes:
template "PHP Template" do |t|
t.filetype = "*.php"
t.location = "templates/phpHTML5.php"
end
7. Save and Restart Aptana.
NOTE: You may 'delete' the project PHP but be careful to deselect the "Delete project contents on disk(cannot be undone)" otherwise you will be in trouble...
Any problems with this just let me know, and I will see if I can help with the rest.

Drupal: Translation template extractor works but the string cannot be found

I'm using Translation template extractor to extract transable strings I've added to my page.tpl.php page in my zen theme files.
I've correctly exporeted zen.pot file and overwritten the previous one. The string 'random text' contained in the t('random text') function in the template is correctly added to the file.
I've refreshed cache, refreshed the tab and run cron again.
However when I search for it in the translation interface I cannot find it and therefore I cannot translate it.
thanks
The solution was to switch the language of the page containing the string at least once to save the string.
Export a .po-file, edit it with (e.g with Poedit) save the file and import it into Drupal.

Resources