About theme editing

Sebastian

Member
I need to add some custom code into the customers footer's layout. I'm editing app/apps/customer/views/layouts/main.php.

Is there a better way to do this without ever touch this core file? Thanks
 
Yes, there is a better way of doing this, via themes or extensions.
What exactly you want to do in the customer footer area?
Are you aware there's an extension called HTML Blocks that will allow you to specifically put html code into customer area?
You just have to enable it from backend -> extend -> Extensions, then click on it's title and you'll get a wysiwyg editor for adding your content.
 
I'm integrating customer.io and I am having hard times extracing some kind of data. Let me shot you (example):
Code:
<script type="text/javascript">
    _cio.identify({
      id: 'prod_287',           
      email: 'user@domain.com', 
      created_at: 1339438758,
      first_name: 'John', 
    });
  </script>

Looking to your existing code I figured out how to extract the full name with
Code:
echo Yii::app()->customer->getModel()->getFullName();
but [...] getFirstName() is not working... and I need to know how to retrieve all this data.

So I need to add php code, HTML blocks won't work form me :)

Then, how do I override those core files? I created a /customer/themes/my_theme/views/main.php but doesn't work. And how do I extract those data?

I'm studying Yii but it's kind hard since I was just starting working with laravel. :D Your help would me a lot appreciated.

PS: Created_at could be mapped to the existing date_added record I can see in the DB table for customers
 
Last edited:
UPDATE: my mistake! Sorry! To override the default views for a custom theme we should add new files to this path:

Code:
 /customer/themes/YOUR_THEME_NAME/views/layout/main.php

And so for any other view. Cool, it works! Now I just need to extract the other datas.
 
@Sebastian
Open the file apps/common/models/Customer.php and at the start of the file you have all the customer fields and inside that file you also have all available methods.
For example:
PHP:
<?php $customer = Yii::app()->customer->getModel();?>
<script type="text/javascript">
_cio.identify({
id: 'prod_287',
email: '<?php echo $customer->email;?>',
created_at: '<?php echo strtotime($customer->date_added);?>',
first_name: '<?php echo $customer->first_name;?>',
});
</script>
It's really not that hard :D
 
Got it!
Code:
Yii::app()->customer->getId()
Sure sure sure, we should look for the User's models inside /app/models/Customer.php
 
Yeah! You answered just a second before. :D Yes, I'm new to MVC and I sometimes fall into those stupid questions! :D sorry for that.

THANKS!!!!!
 
What about using hooks? For example this:
Code:
<footer>
              <?php $hooks->doAction('layout_footer_html', $this);?>
              <div class="clearfix"><!-- --></div>
</footer>

How do I add code to that hook? Plus, is there priority system like wordpress do? :)
 
@Sebastian -
For your particular example, from a theme or extension file, in the run() method, you can hook like:
PHP:
Yii::app()->hooks->addAction('layout_footer_html', function($controller){
    echo "Added this in footer, called from: " . get_class($controller);
}, 10);
The third param is optional, that is the priority.

Like wordpress, mailwizz's Yii::app()->hooks object has methods like: hasFilter / addFilter / applyFilters / hasAction / addAction / doAction / removeAction / removeFilter / etc. You can look inside apps/common/components/managers/HooksManager.php to see them all.
 
Back
Top