Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SOLVED How to hook filter to component content?
#2
There is no such a hook exists. There is a function get_component(), but it is really useless because it does not return the component but processes it immediately (should normally be named "exec_component"). Don't waste your time on it, rather create a custom function/plugin instead.

You can execute your function on any action and alter the content of your component:
PHP Code:
add_action('theme-header''modify_component', array('your-component-slug')); 

And the function may look like this:
PHP Code:
function modify_component($id) {
 
   global $components;

 
   if(!$components) {
        
$components = array();
 
       if(file_exists(GSDATAOTHERPATH.'components.xml')) {
 
           $data getXML(GSDATAOTHERPATH.'components.xml');
 
           $components $data->item;
 
       }
 
   }
 
   
    foreach
($components as $component) {
 
       if($component->slug == $id) {
 
           $newValue 'New component value';
 
           $component->value $newValue;
 
       }
 
   }    

Reply


Messages In This Thread
RE: How to hook filter to component content? - by Bigin - 2020-08-26, 22:28:40



Users browsing this thread: 1 Guest(s)