In a website I'm working on, a javascript file (and a css too) gets downloaded even if the feature it's related with is not present on the page. Since that plugin doesn't allow to load the files only when needed, I wanted to use a wordpress hook to dequeue them when not necessary.
To know if this scripts are needed, I could check inside the html code if a specific element is present (using regex or another method), but I don't know which hook to use and how to get the html data. Could anyone show me how to do it or even just point me to some documentation about it?
Related
hello all i need to change the style of Joomla extension AcySMS but
unable to find where i need to change
here is actual problem i need to change the style so that button must
in front of text box and in country code selection i need to add
county code with the flag of country Thanks :)
I don't know this specific Joomla-extension, but you seem to need two changes:
change the markup of the button
place the button before the input
The first can be done by changing your own custom css-file. Use firebug or developer tools to find out which classes are used and override or extend them in your own css-file.
For the second one, you need to know whether you're using a plugin, a module or a component. The answer to this question leads you to the right Joomla-subfolder. There you will probably find a acysms-folder. Then you'll have to look (even in subfolders) for a file called default.php.
You should use template overrides to manipulate these files, otherwise your changes will be lost with the next regular update of this extension. You can search the Joomla website for help on template overrides. It's not very complicated. https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core
If (for example) you want to make changes to the mod_login module then you would have to copy the file default.php from
PATH_TO_JOOMLA/modules/mod_login/tmpl/
to
PATH_TO_JOOMLA/TEMPLATE_NAME/html/mod_login/
and apply your changes there.
I hope this will get you started.
WHMCS has a feature for providing downloads to clients. The feature can be found in their admin area at /admin/supportdownloads.php
Is there any action hook for when files are uploaded via the admin area? The only related hook I can find is for when files are downloaded.
What I want do to is add a hook so any file I upload is added to the list of Associated Downloads for each of my products. With all the hook options they have, I'm surprised I can't find one for this...
While I have not done exactly what you are trying to do, I can tell you that anything you put in the /includes/hooks folder gets executed, regardless of whether it is actually hooked into a specific point. This is incredibly useful for those moments where there aren't any hook points available (or they are documented as being present but not on certain page renders).
So in a php file in the /includes/hooks folder, I start by echoing out the globals variable. WHMCS stores a lot of information in the globals variable that easily permits you to deduce which page you are on. For example, in one of my hooks, I have a function that determines what the file name is that I am on simply by calling up get_filename(); That function checks the request URI and finds the php file being called. If the filename is one I'm looking for (for example 'dologin') I can isolate the code being executed. You continue to isolate based on the page you are looking for (for example, if each request has a certain variable, or requires being logged in you look for those variables).
Once you are sure you have to be on the page in order for the code to fire, then you can write your PHP to grab the form posted data and store it how you like in a secondary table. The only catch is if the form must first be stored into the database, so you need a unique identifier, but that can be gotten around also.
Hope that is of help...
I have created a snippet that takes specified code and minifies it, but I'm looking to turn this into a plugin to streamline the process. I'm looking to have the code minify when I save a file, and create a new file in that directory with a new name. I have this working as a snippet, but I don't want to be writing files every time the page is loaded.
Is there a way to check when a file (in the Files Tab/Assets) is saved in ModX, and then execute a plugin? I looked through the existing System Events, and didn't find anything.
Looks like you have 3 system events that may work for you: OnFileManagerUpload, OnFileEditFormPrerender & OnFileCreateFormPrerender. My guess would be OnFileManagerUpload.
Docs here:
http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins/system-events/onfilemanagerupload
Though it's important to note [the last time I checked] that even if a system event is listed in the manager and/or documented, they are not all implemented [i.e. won't work] - best to check on this in the modx forums or dig through the code to see if it actually exists.
Now, you are trying to do this from the manager or some front end form?
In the manager attaching a plugin to the OnFileManagerUpload hopefully works. In the front end you may have to attach your plugin to one of the page rendering events either read the file's time/date or append/prepend a timestamp within the file itself.
[or if you are using formit, you can probably use a custom hook to get the job done as well]
I want to make a wordpress site that refreshes only the content/post part and not the header, navigation, footer or the sidebar.
Is this possible? If yes then how?
If you want most of the elements to remain in place you are not refreshing necessarily. What you would want to do is an AJAX request to retrieve the new information for the_content and update the DOM with JavaScript.
You would need a function that intercepts the click event for links, handles the AJAX, and then returns false to prevent navigating away from the page.
What you try to achieve is technically possible, however your wordpress theme must support that. You need to use AJAX for it and your theme needs to provide server endpoints for the type of content that is going to be requested.
This can be done by providing fragment templates inside your theme which only return the fragment in question (e.g. content column, menu). However depending on your site's layout this might not be always possible, e.g. if the layout changes from one page to another.
A possible workaround is to request the new page via AJAX and only replace the parts inside the DOM that are changed.
In any case you need to register an AJAX PHP callback function within wordpressCodex.
I'm quite new to Drupal and want do some editing of the header. I want a custom toolbar to appear on every page. I've already created that toolbar in a file called toolbar.php. It has a layer which is fixed and will appear on top of every page.
How do I include the toolbar.php in the header template of drupal?
The toolbar refers to $user which is a global Drupal variable and I want to test toolbar.php before publishing it to the site. Is there anyway I can do that?
Regards,
Dasith
Of the two methods above the first is easier if you understand the basic idea of html and CMS templates, the second will be easier if you are a programmer.
First thing to check is that you really need to do this! Can't you restyle one of the existing menus (Primary or secondary) to do this - will make your life (and anyone who works on the site in the future) a lot easier.
The other thing you can do is look into adding an output region, basically something where you put the php into a drupal friendly format and then effectively do a 'drupal print'. This is how the toolbar, search box etc are done. You still need to alter the templates as above.
Yes for sure. If you want to have the html produced by your function/file appear on every page of the site then you will need to over-ride the page.tpl.php file in the theme you are using and essentually add the html to that file.
To gain access to the $user variable, just declare it in your script.
global $user;
open page.tpl.php file in a code editor and save as page-front.tpl.php (with two dashes if you are using Drupal 7.. one dash with Drupal 6) and upload it to your theme's directory. Clear your cache by going to configuration->Performance->Clear All Cache. Then referesh the page. Now your homepage is using page-front.tpl.php as it's template file. Every page will need its own template file. The page machine name comes after the hyphen so the user page template uses page-user.tpl.php. You can edit it as you want. The proper way to really do this is to use hook_theme() to pass variables to the template file. One variable could be the html which creates your custom header.
See also http://drupal.org/node/457740 Beginners Guide to over riding theme output