gantry / gantry5

:rocket: Next Generation Template / Theme Framework
http://gantry.org
1.03k stars 203 forks source link

Wordpress 404 error - Not loading the error outline #2449

Open joomlabeat opened 5 years ago

joomlabeat commented 5 years ago

On Wordpress when I hit a 404 page, gantry won't load the error outline (_error layout). Default outline is still loading. So, I am trying to add custom particles and styling on my 404 outline but I can't show them in the 404 front output. What may be causing this?

newkind commented 5 years ago

Check your 404.php file if it's set up correctly. You can compare it to the Helium 404.php file to be sure.

joomlabeat commented 5 years ago

I guess you mean if it's setting the layout to the error one inside the 404 php. My bad that I didn't mention it and although I m out now, I remember the 404 template file is the original gantry one and that is using the setlayout method to set the _error outline before rendering.

Sent from my iPhone

On 16 Jan 2019, at 12:07, NewKind notifications@github.com wrote:

Check your 404.php file if it's set up correctly. You can compare it to the Helium 404.php file to be sure.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

joomlabeat commented 5 years ago

So - I have the 404.php which gets loaded on a 404 error. It's the core gantry 404.php, it contains:

$gantry = Gantry\Framework\Gantry::instance();
$theme  = $gantry['theme'];

$theme->setLayout('_error', true);
newkind commented 5 years ago

What's your layout YAML?

joomlabeat commented 5 years ago

@newkind :: I am not sure I understand what you ask with this question. Do you mean what is the name of the layout, or something else?

newkind commented 5 years ago

Can you paste the whole YAML of your layouts/_error.yaml ?

joomlabeat commented 5 years ago

Sure @newkind , here you are:

/layouts/_error.yaml

version: 2
preset:
  image: 'gantry-admin://images/layouts/default.png'
  name: _error
  timestamp: 1457453164
layout:
  /navigation/:
    -
      - 'logo-9608 15'
      - 'menu-6409 65'
      - 'social-3171 20'
  /header/:
    -
      - custom-8642
  /intro/: {  }
  /features/: {  }
  /utility/: {  }
  /above/: {  }
  /testimonials/: {  }
  /expanded/: {  }
  /container-main/:
    -
      -
        'mainbar 75':
          -
            - system-content-1587
      -
        'sidebar 25': {  }
  /footer/:
    -
      - 'logo-9571 10'
      - 'copyright-1736 30'
      - 'horizontalmenu-9034 45'
      - 'totop-8670 15'
  /offcanvas/:
    -
      - mobile-menu-5697
structure:
  navigation:
    type: section
    attributes:
      boxed: ''
  header:
    type: section
    subtype: header
    attributes:
      boxed: ''
      class: ''
  intro:
    type: section
    attributes:
      boxed: ''
  features:
    type: section
    attributes:
      boxed: ''
  utility:
    type: section
    attributes:
      boxed: ''
      class: ''
  above:
    type: section
    attributes:
      boxed: ''
  testimonials:
    type: section
    attributes:
      boxed: ''
  expanded:
    type: section
    attributes:
      boxed: ''
  mainbar:
    type: section
    subtype: main
    attributes:
      class: ''
    block:
      variations: center
  sidebar:
    type: section
    subtype: aside
  container-main:
    attributes:
      boxed: ''
  footer:
    type: section
    subtype: footer
    attributes:
      boxed: ''
  offcanvas:
    attributes:
      boxed: ''
content:
  logo-9608:
    title: 'Logo / Image'
  social-3171:
    block:
      class: g-social-header
  custom-8642:
    title: 'Custom HTML'
    attributes:
      html: "<h2 class=\"g-title\">We are sorry!</h2>\n<p>Gantry 5 provides a custom error page for you to configure with either positions, particles or a combination of both, as well as styling.</p>"
  logo-9571:
    title: 'Logo / Image'
    attributes:
      image: 'gantry-media://logo/logo-footer.svg'
  horizontalmenu-9034:
    title: 'Horizontal Menu'
    attributes:
      items:
        -
          text: Gantry
          link: 'http://gantry.org'
          name: Gantry
        -
          text: Documentation
          link: 'http://docs.gantry.org'
          name: Documentation
        -
          text: Download
          link: 'http://gantry.org/downloads'
          name: Download
  totop-8670:
    title: 'To Top'

Adding also the .yaml contents from the custom/config/_error

/custom/config/_error/index.yaml

name: _error
timestamp: 1547538142
version: 7
preset:
  image: 'gantry-admin://images/layouts/2-col-right.png'
  name: default
  timestamp: 1539840824
positions: {  }
sections:
  navigation: Navigation
  intro: Intro
  info: Info
  copyright: Copyright
  header: Header
  mainbar: Mainbar
  footer: Footer
  offcanvas: Untitled
particles:
  messages:
    system-messages-4358: 'System Messages'
  logo:
    logo-9062: 'Logo / Image'
    logo-7340: 'Logo / Image'
  menu:
    menu-6594: Menu
    menu-3486: Menu
  custom:
    custom-8750: 'Custom HTML'
    custom-3822: 'Custom HTML'
  content:
    system-content-1587: 'Page Content'
  contactus:
    contactus-1796: Contactus
  spacer:
    spacer-3191: Spacer
    spacer-7837: Spacer
  klnewsletter:
    klnewsletter-1170: 'KL Newsletter'
  social:
    social-2769: Social
  copyright:
    copyright-6079: Copyright
  mobile-menu:
    mobile-menu-5926: Mobile-menu
inherit:
  default:
    navigation: navigation
    system-messages-4358: system-messages-7972
    logo-9062: logo-9608
    menu-6594: menu-6409
    custom-8750: custom-6669
    custom-3822: custom-5864
    footer: footer
    logo-7340: logo-9571
    contactus-1796: contactus-5905
    spacer-3191: spacer-3904
    klnewsletter-1170: klnewsletter-1412
    spacer-7837: spacer-9083
    social-2769: social-5899
    copyright: copyright
    menu-3486: menu-3614
    copyright-6079: copyright-1736
    offcanvas: offcanvas
    mobile-menu-5926: mobile-menu-5697

/custom/config/_error/layout.yaml

version: 2
preset:
  image: 'gantry-admin://images/layouts/2-col-right.png'
  name: default
  timestamp: 1539840824
layout:
  navigation: {  }
  /header/: {  }
  /intro/: {  }
  /container-main/:
    -
      -
        mainbar:
          -
            - system-content-1587
  /info/: {  }
  footer: {  }
  copyright: {  }
  offcanvas: {  }
structure:
  navigation:
    type: section
    inherit:
      outline: default
      include:
        - attributes
        - children
  header:
    attributes:
      boxed: ''
      class: ''
  intro:
    type: section
    attributes:
      boxed: ''
  mainbar:
    type: section
    subtype: main
  container-main:
    attributes:
      boxed: ''
  info:
    type: section
    attributes:
      boxed: ''
  footer:
    inherit:
      outline: default
      include:
        - attributes
        - children
  copyright:
    type: section
    inherit:
      outline: default
      include:
        - attributes
        - children
  offcanvas:
    inherit:
      outline: default
      include:
        - attributes
        - children
newkind commented 5 years ago

Try changing /custom/config/_error/layout.yaml name from name: default to name: _error

joomlabeat commented 5 years ago

Nope - it has no effect. Still I don't get any of the settings applied in the error outline. However maybe it's worth to mention that my body class attribute includes also this "outline-_error" class - when the page is a 404 - alongside with classes of the base outline. - That was happening even before renaming the name for the _error layout.

And another thing that I am not yet 100% is actually happening, but it seems that when there is an outline assignment for a particular page/post type etc... if there is a 404 it will load that assigned outline.

So I am wondering - and starting to think this as a test and possible workaround - if I should create a new outline for my 404 and make an assignment for it - I think I have spotted the 404 as an option in the assignments tree.

joomlabeat commented 5 years ago

Question: When setting the layout via the themes' setLayout method - should the $theme object have the layout as a property defined anywhere? If so I don't see it.

And another thing I am just noticed: On various new outlines that have been created by duplicating older outlines (from the admin), in their yaml files I see as name the name of the outline that have been created from. Is this how it works? Or they should have their own new name? *Those outlines work well by the way for their assignments.

joomlabeat commented 5 years ago

I cloned the 404 (_error) outline and assigned on the 404 Not Found Page - page context assignment and now when in a 404 error - I get the above cloned outline.

*I also did some experiments using the setLayout method on a few templates - and I was getting confusing results - a mix of attributes from the outline that is assigned through gantry admin combined with attributes from the one that is set via the setLayout method. E.g. in the body - I had custom classes that are set on the assigned outline + plus the outline-outline_name of the outline that was set via the php method. I can say more regarding the layout itself and its sections - as I got some confusing output but I didn't have the time to investigate further if that was expected or not - given the assignments and the particles placed on those layouts.

Thanks @newkind for the quick and prompt response - for the time being I will go ahead with my workaround of setting the 404 outline.

plainhavoc commented 5 years ago

Sorry to Frankenstein this thread, but just checking to see if a fix was ever found for this? The workaround mentioned by joomlabeat (cloning error outline and assigning) has no effect on my setup, and trying to learn why. I use Gantry 5 in both Joomla and Wordpress, and it seems only Wordpress is having this issue.