Post by magisterson » Sat Oct 19, 2019 3:30 am

I need to add custom code in <head> section only on contact page. I can't find this functionality in dashboard so I think some if/else code will be needed. Any ideas how to do it?

New member

Posts

Joined
Tue Jul 23, 2013 10:15 pm

Post by d3z1gnr » Sat Oct 19, 2019 3:35 am

This might be what you looking for viewtopic.php?t=171486#p650375

So your route would be 'information/contact'

Mike Little
Director / Developer / Makes the coffee
Creative Digital Limited
http://www.creativedigital.co.nz


User avatar
Active Member

Posts

Joined
Mon Jan 18, 2010 2:59 pm
Location - Auckland, New Zealand

Post by magisterson » Sat Oct 19, 2019 3:47 am

d3z1gnr wrote:
Sat Oct 19, 2019 3:35 am
This might be what you looking for viewtopic.php?t=171486#p650375
So your route would be 'information/contact'
Ok, this could work maybe... but how to add it to theme editor on backend, in this way?

Code: Select all

{% if route == 'xxx/yyy' %}
My code here
 {% endif %}
  

New member

Posts

Joined
Tue Jul 23, 2013 10:15 pm

Post by d3z1gnr » Sat Oct 19, 2019 3:56 am

magisterson wrote:
Sat Oct 19, 2019 3:47 am
Ok, this could work maybe... but how to add it to theme editor on backend, in this way?
Ah, so you do not have access to controller code?

Mike Little
Director / Developer / Makes the coffee
Creative Digital Limited
http://www.creativedigital.co.nz


User avatar
Active Member

Posts

Joined
Mon Jan 18, 2010 2:59 pm
Location - Auckland, New Zealand

Post by magisterson » Sat Oct 19, 2019 3:58 am

I have! But after edit twig file on FTP catalog, and clear cache nothing shows on source code. So I use dashboard theme editor instead.

New member

Posts

Joined
Tue Jul 23, 2013 10:15 pm

Post by d3z1gnr » Sat Oct 19, 2019 4:01 am

Did you try going to Extensions > Modifications and refreshing cache there?

Mike Little
Director / Developer / Makes the coffee
Creative Digital Limited
http://www.creativedigital.co.nz


User avatar
Active Member

Posts

Joined
Mon Jan 18, 2010 2:59 pm
Location - Auckland, New Zealand

Post by magisterson » Sat Oct 19, 2019 4:07 am

But won't that delete my code on backend theme editor? Maybe first I should replace FTP files with my current code in backend editor? I Made lots of changes there.

New member

Posts

Joined
Tue Jul 23, 2013 10:15 pm

Post by d3z1gnr » Sat Oct 19, 2019 4:12 am

Hmmm, might pay to check this viewtopic.php?t=206283
If you have extensions installed and using theme editor (?) this could get messy as they suggest.
Sorry, I'm not helping much.

Mike Little
Director / Developer / Makes the coffee
Creative Digital Limited
http://www.creativedigital.co.nz


User avatar
Active Member

Posts

Joined
Mon Jan 18, 2010 2:59 pm
Location - Auckland, New Zealand

Post by magisterson » Sat Oct 19, 2019 4:18 am

OK, so basicly I shoud now move my whole code from backend theme editor directly to twig files on FTP (just ovverride them)? I prefer to use FTP and Dreamveawer, not this shi*** backend editor :D

New member

Posts

Joined
Tue Jul 23, 2013 10:15 pm

Post by d3z1gnr » Sat Oct 19, 2019 4:23 am

Lol, I've never used it to be fair. Always code using custom extensions or directly to core if it is simple.

Mike Little
Director / Developer / Makes the coffee
Creative Digital Limited
http://www.creativedigital.co.nz


User avatar
Active Member

Posts

Joined
Mon Jan 18, 2010 2:59 pm
Location - Auckland, New Zealand

Post by magisterson » Sat Oct 19, 2019 4:27 am

Yes but I have one more question. I added this code to my header.php controller file:

Code: Select all

$data['route'] = isset($this->request->get['route']) ? $this->request->get['route'] : 'common/home';
And now I need to add if/else in theme file (twig), but I can't add there normal PHP, I need to use there TWIG language. So how to turn this:

Code: Select all

if ($route == 'xxx/yyy') {
My code here
}
To TWIG version?

New member

Posts

Joined
Tue Jul 23, 2013 10:15 pm

Post by d3z1gnr » Sat Oct 19, 2019 4:31 am

You had it right earlier...

Code: Select all

{% if route == 'information/contact' %}
My code here
{% endif %}

Mike Little
Director / Developer / Makes the coffee
Creative Digital Limited
http://www.creativedigital.co.nz


User avatar
Active Member

Posts

Joined
Mon Jan 18, 2010 2:59 pm
Location - Auckland, New Zealand

Post by magisterson » Sat Oct 19, 2019 4:39 am

d3z1gnr wrote:
Sat Oct 19, 2019 4:31 am
You had it right earlier...

Code: Select all

{% if route == 'information/contact' %}
My code here
{% endif %}
This works good.

I asking because I used this tool: https://php2twig.com/index.php and it showed me this:

Code: Select all

{% if route  is  'information/contact' %}
my code
{% endif %}
And ERROR after save :/ "is" not working in OC?

New member

Posts

Joined
Tue Jul 23, 2013 10:15 pm

Post by letxobnav » Sat Oct 19, 2019 12:11 pm

I would use those online php to twig converters with caution as they are all rubbish.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: daniil_oc, pprmkr, WaxedPerfection and 470 guests