Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

variable mount is null on every page #3625

Open
lostika86 opened this issue Apr 30, 2021 · 16 comments · Fixed by #8928
Open

variable mount is null on every page #3625

lostika86 opened this issue Apr 30, 2021 · 16 comments · Fixed by #8928

Comments

@lostika86
Copy link

Bug Description

Mount variable is missing from collections entries. It is attached as in the docs. Last time worked correctly,

How to Reproduce

  1. Create new collection, and define the mount
sites:
  - default
  - hungarian
template: default
layout: layout
mount: 28124839-6062-43bd-8e4e-ca7a11af3b7a
revisions: false
route: '{{mount}}/{{slug}}'
sort_dir: asc
date_behavior:
  past: public
  future: private 
  1. Create an entry and go to url ({{mount}}/{{slug}})

Extra Detail

Few weeks ago worked correctly

Environment

Statamic 3.1.11 Pro
Laravel 8.40.0
PHP 7.3.12
doublethreedigital/duplicator 1.3.1

Install method (choose one):

  • Fresh install from statamic/statamic
@robdekort
Copy link
Contributor

Hmmm, seems to work fine here with this syntax: /{mount}/{slug}.

@lostika86
Copy link
Author

lostika86 commented May 6, 2021

Can you reach the mount variable? {{ mount | dump }} is null for me. Debugbar shows on mount null too

@robdekort
Copy link
Contributor

The mount is set on a collection level and I don't think you can reach it in your template. But your issue is about the actual route giving a 404 right?

So when you visit yoursite.test/mount-slug/entry-slug you got a 404 is what I got from your initial issue.

I noticed you used a different syntax. Have you tried my suggestion?

@jasonvarga
Copy link
Member

mount will be the handle of the collection on the entry that has been mounted to it.

Seems to work fine.

In your example, within entry 28124839-6062-43bd-8e4e-ca7a11af3b7a, {{ mount }} will be the handle of whatever collection's yaml file you pasted.

@robdekort
Copy link
Contributor

I'm not sure what the real issue is tbh. Can you explain in detail what you are trying to achieve and what you think is the issue?

@lostika86
Copy link
Author

The mount is set on a collection level and I don't think you can reach it in your template. But your issue is about the actual route giving a 404 right?

So when you visit yoursite.test/mount-slug/entry-slug you got a 404 is what I got from your initial issue.

I noticed you used a different syntax. Have you tried my suggestion?

The route works fine. I want to reach it in my template, there is a variable, mount:null if I check variables on debugbar

@lostika86
Copy link
Author

lostika86 commented May 10, 2021

I want to simply use in my template for example: {{ mount:title }} .

@lostika86
Copy link
Author

another way to explain:
current entry belongs into categories collection
image
the mount variable is null
image

@jasonvarga
Copy link
Member

What's the id for the current entry in that same debugbar list?

@lostika86
Copy link
Author

The id is
image

---
title: 'Marmolitové omietky'
structures:
  - product_category
updated_by: 20691469-4788-4708-8dee-2c59bc9e1b41
updated_at: 1617195948
id: 8d01eeef-1113-4596-8716-e96a6d94b0ed
---

I thought commit b3b4a179 is for enable mounted entry in template. Maybe I think it wrong...

@lostika86
Copy link
Author

I'm not sure what the real issue is tbh. Can you explain in detail what you are trying to achieve and what you think is the issue?

  1. Create a new collection, dont forget to setup mount.
  2. Create a new entry 'Mountains' in collection
  3. Go to template, where you can reach/use 'Mountains' entry
  4. You will see in debugbar available variables for entry, but variable mount is null

@robdekort
Copy link
Contributor

I think it's supposed to work like that. It's only available on the entry where you mounted the collection on.
I've been in multiple use cases where I need to get a collection's mount entry URL so you can do stuff like "Go back to all news" / "Go back to all mountains".

There's no native tag for this. There is a FR out: statamic/ideas#301 and a solution in the comments (link to forum).

Hope this helps!

@robdekort
Copy link
Contributor

Closing this, feel free to reopen if I'm wrong.

@edalzell edalzell reopened this Feb 2, 2023
@edalzell
Copy link
Contributor

edalzell commented Feb 2, 2023

I'm in a multi-site and the mount var is null on career entry pages (which are mounted to a careers page).

IMO it should be the entry to which that collection is mounted.

@jasonvarga
Copy link
Member

This has been reverted in #9145 as it causes some issues. We'll revisit it in another version.

@jasonvarga jasonvarga reopened this Dec 6, 2023
@isaackearl
Copy link

I'm running into this same issue. If the mount is null, how can I access the page data the collection is mounted on? I too want to be able to do mount:title or something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants