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

Create partials for event pages #135

Closed
mattstratton opened this issue Apr 14, 2016 · 1 comment
Closed

Create partials for event pages #135

mattstratton opened this issue Apr 14, 2016 · 1 comment
Assignees

Comments

@mattstratton
Copy link
Member

This wasn't an issue when we had only one template type, but with the addition of talks/single.html we have some repetition.

Generally speaking, this is what should go into
/themes/devopsdays-legacy/layouts/partials/event_header.html

{{/*
  This section is what creates the query to get at all the site data. If you need this somewhere, you can just copy
  it and paste it. Need to figure out if a partial would expose the variables/elements/array created herein. It could be done in a partial (need to include the trailing .) but I don't think it would work in shortcodes, which is where we need it the most - mattstratton
*/}}

{{ $path := split $.Source.File.Path "/" }}
{{ $event_slug := index $path 1 }}
{{ $event := (print .Params.year (lower .Params.city)) }}
{{ $e :=  (index $.Site.Data.events $event_slug) }}

{{/* end site data query */}}

<div class = "container-fluid">
  <div class="row">
        <div class="col-md-8">
      <h1> {{ $e.city }} {{ $e.year }} - {{ title .Title }} </h1>
      <!-- Main navigation -->
      <div class="submenu">
        <h3>
        {{ range $navigation := $e.navigationelements}}
          <a href="/events/{{ $event_slug }}/{{ $navigation}}">{{ $navigation }}</a>&nbsp;
        {{ end }}
        </h3>
      </div>

And this should go into /themes/devopsdays-legacy/layouts/partials/event_footer.html

    </div>



    <div class="col-md-4">
    <!-- sponsor code begin -->
    {{ $sponsors := $e.sponsors }}
    {{ range $e.sponsor_levels }}
    <h2>{{ .label }} Sponsors</h2>
      {{ range where $sponsors "level" .id }}
        {{ $s :=  (index $.Site.Data.sponsors .id) }}
        {{ if isset $.Site.Data.sponsors .id }}
          <a href = "{{ $s.url }}"><img alt = "{{ .id }}" src = "/img/sponsors/{{ .id }}.png" class="img-responsive company-logo" width = "95px"></a>
        {{ end }}
      {{ end }}
      <div class = "sponsor-cta">
        <a href = "/events/{{ $e.friendly }}/sponsor">Become a {{ .label }} Sponsor!</a>
      </div>
    {{ end }}

    <!-- sponsor code end -->
    </div>
  </div>

</div>
{{ partial "footer.html" . }}

Note that when you want to use the new partials, you will have to call them with the "dot" like so:

{{ partial "event_footer.html" . }}

@mattstratton
Copy link
Member Author

OK, so this isn't super delightful, in that the variables don't get passed around between partials, so this bit of code:

{{ $path := split $.Source.File.Path "/" }}
{{ $event_slug := index $path 1 }}
{{ $e :=  (index $.Site.Data.events $event_slug) }}

has to exist in the template as well as both the event_header.html and event_footer.html template. It's still better than it was; I actually think that when we refactor the data directory in #133 this will change enough that it's not that big of a deal - this all exists just to get that last query, which will be made a lot simpler and more specific to where it is needed anyway. It will go from three lines to one in the data refactor.

@mattstratton mattstratton self-assigned this Apr 14, 2016
mattstratton added a commit that referenced this issue Apr 14, 2016
…artials

Create partials for event pages. Fixes #135
benjohnson77 pushed a commit to benjohnson77/devopsdays-web that referenced this issue May 22, 2016
benjohnson77 pushed a commit to benjohnson77/devopsdays-web that referenced this issue May 22, 2016
…ent-site-partials

Create partials for event pages. Fixes devopsdays#135

Former-commit-id: fd8ccfa
yvovandoorn pushed a commit that referenced this issue May 22, 2016
…artials

Create partials for event pages. Fixes #135
yvovandoorn pushed a commit that referenced this issue May 22, 2016
yvovandoorn pushed a commit that referenced this issue May 22, 2016
…artials

Create partials for event pages. Fixes #135

Former-commit-id: fd8ccfa
yvovandoorn pushed a commit that referenced this issue May 22, 2016
…artials

Create partials for event pages. Fixes #135
yvovandoorn pushed a commit that referenced this issue May 29, 2016
yvovandoorn pushed a commit that referenced this issue May 29, 2016
…artials

Create partials for event pages. Fixes #135

Former-commit-id: fd8ccfa
yvovandoorn pushed a commit that referenced this issue May 29, 2016
…artials

Create partials for event pages. Fixes #135
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

No branches or pull requests

1 participant