Getting current URL in templates.
Hey guys, I'm toying around with the lavender theme and I've moved the save changes button on the settings pages to the top, in the same bar as the "Edit, Settings, Profile" links.
The problem with this is that it will appear even on /followers and /following.
Is there a way to check if the current URL is /followers or /following in the template file?
I'd probably wait for an official answer on that though.
Thanks for that, so in the template how can I use the IF functions, I'm not too sure on this stuff..
<!-- IF location.pathname IS "/followers" --> ?
or = or something else?
<-- IF followers.length --> <-- IF following.length -->
If I use that, it displays only on followers/following page.
!followers.length doesn't seem to work and edit.length doesn't work either so I'm not sure how to do this
You can also use
ELSE. So, if I'm not mistaken, something like
<!-- IF followers.length --> <!-- ELSE --> Code here <!-- ENDIF followers.length -->
May produce better results.
Yep, that works, but there's also another pages using the menu at the top that I've just noticed.
Is there a way to check if the page is just settings or edit?
These seem to be the only ones that need the button.
We can possibly add the name of the current template into the api return. So that you can do stuff like
<!-- IF account/edit--> only shows up on edit page <!-- ENDIF account/edit -->
account/editwill be true when you are on the url
user/:username/editand false everywhere else.
So to solve your problem you would have to do
<!-- IF account/edit--> <!-- IMPORT partials/mySpecialButton.tpl --> <!-- ENDIF account/edit --> <!-- IF account/settings --> <!-- IMPORT partials/mySpecialButton.tpl --> <!-- ENDIF account/settings -->
So you can include a special template if the page is edit or settings.
yeah that makes sense to me. tbh maybe we should add the name of the template for all returns as a global var? so that there's no confusion for any custom routed api call -> templates such as the above routes
Yeah I was thinking of adding it here like this
options[template] = true;