[mezzanine-users] Re: Customizing search URL

2017-09-13 Thread Rainell Dilou Gómez
I have forgotten something, it may be obvious, but it is better to specify 
it. For the above example to work it is necessary to import the search view.
from mezzanine.core.views import direct_to_template, search


Il giorno martedì 5 settembre 2017 12:20:28 UTC+2, si...@e5r.no ha scritto:
>
> Hi, I’m wondering whether there is any smart way to customize the URL
> used for the built-in Mezzanine search view besides the methods
> mentioned below.
>
> Say that you want to change the search URL from the default `search`
> to `my-search`. A first attempt might be:
>
>   url("^my-search/$", search, name="search"),
>   url("^", include("mezzanine.urls")),
>
> Now you get a search page at `my-search`, but the search view still
> redirects to Mezzanine’s `search` since that one is registered later.
>
> This will fix it, but it doesn’t feel optimal:
>
>   url("^(?!my-search/)", include("mezzanine.urls")),
>   url("^my-search/$", search, name="search"),
>
> Another approach is to give `my-search` another name, copying
> `search_form.html` from Mezzanine and changing `{% url "search" %}` to
> use the new name. This works fine, but it feels a bit wasteful unless
> you’d like to customize the template some more, and it creates more
> work if you’d like to receive updates to `search_form.html` from
> future Mezzanine versions.
>
> Could a cure for all of this be to add a setting for the search URL,
> defaulting to `search`?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Customizing search URL

2017-09-13 Thread Rainell Dilou Gómez
I read your initial question again and, if I understood correctly, you 
should do only a couple of things:

1- Create your custom urlpatterns, for example
url ("^my-search/$", search, name="my_search"),
url ("^", include("mezzanine.urls"))

2- create a copy of the template *search_form.html* in this path
your_project_folder/templates/includes/search_form.html

3- modify the action attribute of the form by putting your urlpattern name 
(my_search )


Ready, it works perfectly!


Il giorno martedì 5 settembre 2017 12:20:28 UTC+2, si...@e5r.no ha scritto:
>
> Hi, I’m wondering whether there is any smart way to customize the URL
> used for the built-in Mezzanine search view besides the methods
> mentioned below.
>
> Say that you want to change the search URL from the default `search`
> to `my-search`. A first attempt might be:
>
>   url("^my-search/$", search, name="search"),
>   url("^", include("mezzanine.urls")),
>
> Now you get a search page at `my-search`, but the search view still
> redirects to Mezzanine’s `search` since that one is registered later.
>
> This will fix it, but it doesn’t feel optimal:
>
>   url("^(?!my-search/)", include("mezzanine.urls")),
>   url("^my-search/$", search, name="search"),
>
> Another approach is to give `my-search` another name, copying
> `search_form.html` from Mezzanine and changing `{% url "search" %}` to
> use the new name. This works fine, but it feels a bit wasteful unless
> you’d like to customize the template some more, and it creates more
> work if you’d like to receive updates to `search_form.html` from
> future Mezzanine versions.
>
> Could a cure for all of this be to add a setting for the search URL,
> defaulting to `search`?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: Customizing search URL

2017-09-13 Thread simen
tirsdag 12. september 2017 22.19.52 UTC+2 skrev christia...@googlemail.com 
følgende:
>
> If you add something like "url("^search/$", mysearch, name="search")" in 
> the main urls.py of your app above "url("^", include("mezzanine.urls"))," 
> it should work. I just tried it and it addressed my custom "mysearch" 
> perfectly.
>

That works because you’re using the same URL pattern as Mezzanine. If
you change it to `("^mysearch/$", search, name="search")`, where
`search` is Mezzanine’s search view, reverse lookup will still give
you Mezzanine’s URL since it’s defined later.

I’m wondering whether there is a better way to override it than:

  url("^(?!mysearch/)", include("mezzanine.urls")),
  url("^mysearch/$", search, name="search"),

-- Simen 

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: Customizing search URL

2017-09-12 Thread christian.kuper1 via Mezzanine Users
If you add something like "url("^search/$", mysearch, name="search")" in 
the main urls.py of your app above "url("^", include("mezzanine.urls"))," 
it should work. I just tried it and it addressed my custom "mysearch" 
perfectly.


Am Dienstag, 12. September 2017 17:19:20 UTC+2 schrieb si...@e5r.no:
>
> tirsdag 12. september 2017 14.14.13 UTC+2 skrev Christian Kuper følgende:
>>
>> Just create a new empty template and put {% extends 'template_to_extend' 
>> %} at the top. Then you get a template with your custom name and the same 
>> content as the build in template.
>>
>
> Yes, but that doesn’t override the form action URL constructed on line
> 2 in `search_form.html`, right?
>
> -- Simen
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: Customizing search URL

2017-09-12 Thread Eduardo Rivas
Yes it will, because the template uses the {% url %} tag and will 
respect your urlpatterns. Just make sure you set name="search" in your 
overridden pattern.


On 2017-09-12 9:19 AM, si...@e5r.no wrote:

tirsdag 12. september 2017 14.14.13 UTC+2 skrev Christian Kuper følgende:

Just create a new empty template and put {% extends
'template_to_extend' %} at the top. Then you get a template with
your custom name and the same content as the build in template.


Yes, but that doesn’t override the form action URL constructed on line
2 in `search_form.html`, right?

-- Simen
--
You received this message because you are subscribed to the Google 
Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to mezzanine-users+unsubscr...@googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Mezzanine 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: Customizing search URL

2017-09-12 Thread simen
tirsdag 12. september 2017 14.14.13 UTC+2 skrev Christian Kuper følgende:
>
> Just create a new empty template and put {% extends 'template_to_extend' 
> %} at the top. Then you get a template with your custom name and the same 
> content as the build in template.
>

Yes, but that doesn’t override the form action URL constructed on line
2 in `search_form.html`, right?

-- Simen

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: Customizing search URL

2017-09-12 Thread 'Christian Kuper' via Mezzanine Users
Just create a new empty template and put {% extends 'template_to_extend' %}
at the top. Then you get a template with your custom name and the same
content as the build in template.

Am 12.09.2017 1:05 nachm. schrieb :

> tirsdag 12. september 2017 13.50.33 UTC+2 skrev Christian Kuper følgende:
>>
>> Not sure why you consider creating a custom template as not optimal. IMHO
>> templates are for customizing.
>>
>> Create a custom template which extends the build in template, and all
>> updates of the core framework will be implemented.
>>
>
> Hi.
>
> Mezzanine’s `search_form.html` template doesn’t have any `block` tags,
> so as far as I know you'll have to make a copy of it in order to make
> changes to it. Or am I missing something?
>
> -- Simen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mezzanine Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mezzanine-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: Customizing search URL

2017-09-12 Thread simen
tirsdag 12. september 2017 13.50.33 UTC+2 skrev Christian Kuper følgende:
>
> Not sure why you consider creating a custom template as not optimal. IMHO 
> templates are for customizing.
>
> Create a custom template which extends the build in template, and all 
> updates of the core framework will be implemented.
>

Hi.

Mezzanine’s `search_form.html` template doesn’t have any `block` tags,
so as far as I know you'll have to make a copy of it in order to make
changes to it. Or am I missing something?

-- Simen

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [mezzanine-users] Re: Customizing search URL

2017-09-12 Thread 'Christian Kuper' via Mezzanine Users
Hi,

Not sure why you consider creating a custom template as not optimal. IMHO
templates are for customizing.

Create a custom template which extends the build in template, and all
updates of the core framework will be implemented.

Regards

Chris


Am 12.09.2017 8:02 vorm. schrieb :

Hi Rainell.

That’s indeed the second approach I tried to describe. It works well,
but for such a small thing as changing the search URL part it doesn’t
feel optimal. When doing so you have to watch out for changes to
Mezzanine’s built-in `search_form.html` in future releases and
backport it to your custom one if you’d like to benefit from
improvements made to it.

Also I imagine wanting to change the default search URL is very common
when working with non-English sites, so why not add a setting for it,
similar to the `BLOG_SLUG` setting?

-- Simen

-- 
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Customizing search URL

2017-09-12 Thread simen
Hi Rainell.

That’s indeed the second approach I tried to describe. It works well,
but for such a small thing as changing the search URL part it doesn’t
feel optimal. When doing so you have to watch out for changes to
Mezzanine’s built-in `search_form.html` in future releases and
backport it to your custom one if you’d like to benefit from
improvements made to it.

Also I imagine wanting to change the default search URL is very common
when working with non-English sites, so why not add a setting for it,
similar to the `BLOG_SLUG` setting?

-- Simen

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Customizing search URL

2017-09-11 Thread Rainell Dilou Gómez
Sorry, I did not understand all your question well, to my first answer I 
must add that the search form displayed on the site is nothing more than a 
block of the base.html template
{% block navbar_search_form%} {% search_form "all"%} {% endblock%}
where search_form is nothing more than a template-tag. Then you can create 
a template that extends *base.html* and include the navbar_search_form 
block with a custom template-tag
{% block navbar_search_form%} {% my_custom_template_tag_for_search%} {% 
endblock%}




Il giorno martedì 5 settembre 2017 12:20:28 UTC+2, si...@e5r.no ha scritto:
>
> Hi, I’m wondering whether there is any smart way to customize the URL
> used for the built-in Mezzanine search view besides the methods
> mentioned below.
>
> Say that you want to change the search URL from the default `search`
> to `my-search`. A first attempt might be:
>
>   url("^my-search/$", search, name="search"),
>   url("^", include("mezzanine.urls")),
>
> Now you get a search page at `my-search`, but the search view still
> redirects to Mezzanine’s `search` since that one is registered later.
>
> This will fix it, but it doesn’t feel optimal:
>
>   url("^(?!my-search/)", include("mezzanine.urls")),
>   url("^my-search/$", search, name="search"),
>
> Another approach is to give `my-search` another name, copying
> `search_form.html` from Mezzanine and changing `{% url "search" %}` to
> use the new name. This works fine, but it feels a bit wasteful unless
> you’d like to customize the template some more, and it creates more
> work if you’d like to receive updates to `search_form.html` from
> future Mezzanine versions.
>
> Could a cure for all of this be to add a setting for the search URL,
> defaulting to `search`?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[mezzanine-users] Re: Customizing search URL

2017-09-11 Thread Rainell Dilou Gómez
Just import the mezzanine search view
from mezzanine.core.views import direct_to_template, *search*
your first example wil work well
url("^my-search/$", search, name="search"),
url("^", include("mezzanine.urls")),


Il giorno martedì 5 settembre 2017 12:20:28 UTC+2, si...@e5r.no ha scritto:
>
> Hi, I’m wondering whether there is any smart way to customize the URL
> used for the built-in Mezzanine search view besides the methods
> mentioned below.
>
> Say that you want to change the search URL from the default `search`
> to `my-search`. A first attempt might be:
>
>   url("^my-search/$", search, name="search"),
>   url("^", include("mezzanine.urls")),
>
> Now you get a search page at `my-search`, but the search view still
> redirects to Mezzanine’s `search` since that one is registered later.
>
> This will fix it, but it doesn’t feel optimal:
>
>   url("^(?!my-search/)", include("mezzanine.urls")),
>   url("^my-search/$", search, name="search"),
>
> Another approach is to give `my-search` another name, copying
> `search_form.html` from Mezzanine and changing `{% url "search" %}` to
> use the new name. This works fine, but it feels a bit wasteful unless
> you’d like to customize the template some more, and it creates more
> work if you’d like to receive updates to `search_form.html` from
> future Mezzanine versions.
>
> Could a cure for all of this be to add a setting for the search URL,
> defaulting to `search`?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mezzanine-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.