I'm looking to add (what I call, might go by another name) Dynamic Account Links to my website, so when the user is logged out, the link would say "Sign In" and then "Sign Out" when the user is logged in.
I figured I'd put the Register link on the Sign In page.
I'm using Adobe Business Catalyst.
I've found related questions on here but they all seem to relate to Ruby and Magento.
Could anyone shed some light on this matter?
Many thanks.
If you have Liquid Markup enabled, you can serve just the correct html like this:
{% if globals.user.isLoggedIn -%}
...Sign Out link...
{% else -%}
...Sign In link...
{% endif -%}
Without Liquid Markup, you'll need to get CSS involved:
<div class="visible-iff-true--{module_isloggedin}">
...Sign Out link...
</div>
<div class="visible-iff-false--{module_isloggedin}">
...Sign In link...
</div>
.visible-iff-true--0,
.visible-iff-false--1 {
display: none;
}
.visible-iff-true--1,
.visible-iff-false--0 {
display: block;
}
Related
What's the best way to build a reusable DRY section in liquid assuming the store owner wants to choose new options each time the section is reused?
Here are the two methods I can find:
Create a snippet which I can include from any template file, but
this won't allow the store owner to customize the settings. Keeps things very DRY but with no customization which defeats the purpose.
Create a section with settings, which includes a reusable snippet. But I need to duplicate this section every time I want to use it on a different page. Requires me to create duplicates of all my sections every time I create a new page.
Option 1:
reusable_snippet.liquid:
<div>
<h1>I'm a reusable non customizable quote</h1>
</div>
random_page_1.liquid:
{% include 'reusable_snippet' %}
random_page_2.liquid:
{% include 'reusable_snippet' %}
Option 2:
reusable_customizable_snippet.liquid:
<div>
<h1>{{ section.settings.full_msg_title }}</h1>
</div>
non_reusable_section_1.liquid:
{% include 'reusable_customizable_snippet' %}
{% schema %}
{
"name": "Reusable Snippet",
"settings": [{
"type": "text",
"id": "full_msg_title",
"label": "Full Width Message Title"
}]
}
{% endschema %}
non_reusable_section_2.liquid:
{% include 'reusable_customizable_snippet' %}
{% schema %}
{
"name": "Reusable Snippet",
"settings": [{
"type": "text",
"id": "full_msg_title",
"label": "Full Width Message Title"
}]
}
{% endschema %}
Is there some other, better method to create a reusable, individually customizable section?
It depends of what your section requirements.
If you don't have too many options in that section and your are not using the blocks from it, you can create dynamic blocks, where you will choose each page that the block will be visible on.
If you have too many options or you are using already the blocks, there a still a few ways depending on the information you need to add.
1) Using navigations & pages/articles etc..
Each link can point to a separate page from which you can use the content text or the content and excerpt if it's a blog post.
2) Metafields
Use metafeilds, there is a free APP that support metafields only on the product pages or you can use an extension for the ShopifyFD and use those instead for each page you like to have custom information.
To sum up it all depends on the amount of custom information you plan to edit.
I wrote a simple angular application in a learning purpose. However the controllers are working in my system but not in plunker. But, that is not my concern. My concern is I am unable to see the linked pages inside ng-view. They are rather opening as a new page replacing the home page. Secondly, the expressions are not reflecting their values. Kindly help me out. I have uploaded the codes in plunker.
Link to Plunker
<div ng-controller="RamFirstCtrl">{{name}}</div>
<div ng-include="'navbar-top.html'"></div>
<div style="border:1px solid green; position:relative;" ng-view></div>
Noticed couple thing:
http to https, there is error in console, it might be the reason it doesn't work in plunker
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.js"></script>
you have to use the url define in your router:
ng-href="aboutUS.html" to ng-href="#!/aboutUS"
.when("/aboutUS", {
templateUrl : "aboutUS.html"
})
<div>
<a ng-href="#!/aboutUS">
AboutUs
</a>
</div>
Note:#! will be added to url by angular router by default
I have recently set up a website that uses cloudflare free ssl. When using ajax calls for pagination I get a mixed content error, I assume because it's still at some point transmitted over http!? I tried using the instructions for https redirect here: https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl
but that just ended up in a loop, giving the too many redirects error.
This is the specific error relating to mixed content:
Mixed Content: The page at
'https://www.andysmobilearchery.co.uk/events/' was loaded over HTTPS,
but requested an insecure XMLHttpRequest endpoint
'http://www.andysmobilearchery.co.uk/events/index/?page=2&x-requested-with=xmlhttprequest&=1502287619453'.
This request has been blocked; the content must be served over HTTPS.
Is there a fix for this, or am I going to have to remove the ajax functions?
Any help is appreciated!
#if (Model.Pager.EndPage > 1)
{
<ul class="pagination">
#if (Model.Pager.CurrentPage > 1)
{
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" asp-route-page="1" data-ajax-method="GET" asp-route-dfrom="#ViewBag.dfrom" asp-route-dto="#ViewBag.dto" asp-route-search="#ViewBag.search">First</a>
</li>
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="#(Model.Pager.CurrentPage - 1)" asp-route-dfrom="#ViewBag.dfrom" asp-route-dto="#ViewBag.dto" asp-route-search="#ViewBag.search">Previous</a>
</li>
}
#for (var page = Model.Pager.StartPage; page <= Model.Pager.EndPage; page++)
{
<li class="#(page == Model.Pager.CurrentPage ? "active" : "")">
<a asp-controller="Events"asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="#page" asp-route-dfrom="#ViewBag.dfrom" asp-route-dto="#ViewBag.dto" asp-route-search="#ViewBag.search">#page</a>
</li>}
#if (Model.Pager.CurrentPage < Model.Pager.TotalPages)
{
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="#(Model.Pager.CurrentPage + 1)" asp-route-dfrom="#ViewBag.dfrom" asp-route-dto="#ViewBag.dto" asp-route-search="#ViewBag.search">Next</a>
</li>
<li>
<a asp-controller="Events" asp-action="_Index" data-ajax="true" data-ajax-mode="replace" data-ajax-update="#paged-content" data-ajax-method="GET" asp-route-page="#(Model.Pager.TotalPages)" asp-route-dfrom="#ViewBag.dfrom" asp-route-dto="#ViewBag.dto" asp-route-search="#ViewBag.search">Last</a>
</li>
}
</ul>
}
I have now noticed that other sites where I have this implemented work just fine (3 others!), I am using asp.net boilerplate which adds a trailing slash to urls, if I disable this the events page works, but my reviews page stops... I am baffled lol
So I found the answer, kind of.
In my app I had the routing option to add the trailing slash:
.AddRouting(
options =>
{
// Improve SEO by stopping duplicate URL's due to case differences or trailing slashes.
// See http://googlewebmastercentral.blogspot.co.uk/2010/04/to-slash-or-not-to-slash.html
// All generated URL's should append a trailing slash.
options.AppendTrailingSlash = true;
// All generated URL's should be lower-case.
options.LowercaseUrls = true;
})
I found that disabling this worked, however I wasn't content given that this issue doesn't arise on my other sites. In the end I copied the startup.cs from a working site, which has fixed the issue, the only difference that I can find is that the broken site uses a partial class for startup and in the files which make up the rest of the start up the only difference was a cors method, I have no need for cors so I don't know why it was there, still that shouldn't have broken it. It's going to have to remain a mystery for a while since I have it working. What I am going to do is re-contsruct the app bit by bit at a later date; if I remember I'll update here with any findings.
I have created an OctoberCMS theme which works very well. And i have my current and activated theme.yaml like this.
theme.yaml
name: 5P Group
description: '5P Group OctoberCMS theme. A client website that contains preconfigured pages for static pages, a blog and client area..'
author: Technobrave
homepage: 'http://technobrave.com/'
code: ''
form:
fields:
site_logo:
label: Site Logo
comment: The website logo as it should appear on the front-end
type: fileupload
mode: image
imageHeight: 32
imageWidth: 443
As you can see i have added a Site Logo label through which admin can upload a logo and i will show it up front, which is working fine as i am able to show logo at front area like this.
menu.htm
{% if this.theme.site_logo %}
<img src="{{ this.theme.site_logo.path }}" width="100%" height="auto"/>
{% else %}
<img src="{{ 'assets/images/logo.png'|theme }}" width="100%" height="auto"/>
{% endif %}
But the thing is i am also creating an api and i want to do the same thing in that api. This is what i am trying.
routes.php
use System\Classes\SettingsManager;
/* API to get Website Logo Dynamically Starts */
Route::post('/getWebsiteLogo', function ()
{
$settings = Settings::instance();
print_r($settings);
});
/* API to get Website Logo Dynamically Ends */
But i am having an error saying
Class 'Settings' not found
Can someone guide me or suggest me how can i accomplish the same thing, or say how to get the dynamic website logo in one of my apis ?
Thanks
Ok guys, thanks for your support .. eventually i have worked around like this.
routes.php
<?php
use Cms\Classes\ComponentBase;
use RainLab\Pages\Classes\Router;
use Cms\Classes\Theme;
/* API to get Website Logo Dynamically Starts */
Route::post('/getWebsiteLogo', function ()
{
$theme = Theme::getActiveTheme();
$logo_url = '';
if($theme->site_logo['attributes']['disk_name'])
{
echo $theme->site_logo->path;
}
}
?>
Thanks for help and support. Highly appreciated.
I am making a Reddit app for the iPhone, and part of the app's functionality requires posting new stories (i.e. links or text) to Reddit.
When I attempt this, I make the following request and set the request's cookie based on a past login attempt:
http://www.reddit.com/api/submit/?uh=%#&text=TestofAPISubmitonapigee&kind=self&sr=redditdev&title=APISubmitTest&r=redditdev&api_type=json
(where %# is replaced by the user modhash, something along the lines of aa4aaaa3aaaaaa88ea8b19639c389521a813d21cb3e5688dbf)
Upon submitting the request, however, I receive this response:
<html>
<head>
<title>reddit broke!</title>
</head>
<body>
<div style="margin: auto; text-align: center">
<p>
<a href="/">
<img border="0" src="http://www.redditstatic.com/youbrokeit1.png" alt="you broke reddit" />
</a>
</p>
<p>
I've made a huge mistake!
</p>
</body>
</html>
Or a variation on the above message. Any thoughts on what I'm doing wrong?
I figured it out. All you have to do is put the POST data in the HTTP body of the NSMutableURLRequest using [request setHTTPBody:#"NSString of the POST data"]; rather than the above, which is technically a GET request. I found this confusing, since this method worked for logging in to Reddit using the API. It turns out that you can login by GETting, but you must POST to share a new link.