Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Make it possible to reuse a view #118

Closed
dennohpeter opened this issue Feb 11, 2020 · 4 comments
Closed

Make it possible to reuse a view #118

dennohpeter opened this issue Feb 11, 2020 · 4 comments

Comments

@dennohpeter
Copy link

I think it would be nice to make it possible to reuse a specific view from different templates i.e more details view.
Example:
On my case I have

  • Programmes template
  • current projects template
  • ...etc
    Models
  • Programmes
  • CurrentProjects

Each model has multiple items each with it own more-info-link and they will both be reusing the same moreinfo template
Am finding it repetitive to generate same view structure but with different model to be referenced in the templates above.

So my suggestion was, it would be nice if the next release{before the breaking change 👉 } #109 would make it possible to reuse a view something like this on templates on each loop

## programmes template
<a href="{% url 'moreDetails', programmes %}" class="btn
              btn-primary btn-outline-theme">Read More</a>
## currentProjects template
<a href="{% url 'moreDetails', currentProjects %}" class="btn
              btn-primary btn-outline-theme">Read More</a>

Through the following approache:

  • only changing model name and generating the corresponding the path templates
path:
  template: /{{ post.read_more_link }}/
  for-each: 
    post: session.query(**SomeplaceholderModelName**).all()
template: moreDetails
  • add support for multiple paths on the same view
path:
  template: /{{ post.read_more_link }}/
  for-each: 
    post: session.query(Programmes).all()
path:
  template: /{{ post.read_more_link }}/
  for-each: 
    post: session.query(CurrentProjects).all()
template: moreDetails
  • make it possible for session.query(Model1, Model2, Model2, ..etc) to query multiple Models and return the as list which can be later be used to make multiple template paths
  • and any other better way 😃
@dennohpeter
Copy link
Author

@thanethomson

@thanethomson
Copy link
Owner

If I were in your situation, I'd:

  1. Generate one full HTML file that contains the summary of the model from one Statik view
  2. Generate a partial HTML file that just contains the details of the model using another Statik view
  3. On clicking the "More Details" link/button, fetch the more detailed model via an AJAX request and replace the summary with the details.

Multiple paths on a single view totally breaks Statik's entire data model.

@dennohpeter
Copy link
Author

okay thank you

@dennohpeter
Copy link
Author

closing the issue now, I decided to go the old school, have more details view for each different category

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

No branches or pull requests

2 participants