3 Replies Latest reply on May 6, 2013 9:50 AM by thetrickster888

    Make a slider link to a root-relative or arbitrary URL?




      I am using the slider that came with a default BC template (I believe it is the nivo slider), and it gives me options for Item Name, URL, & Image.


      The URL that the slider links to currently has to be relative to the web app's directory, so for example I can only link to mydomain.com/slider/somepage when really I just want to link to mydomain.com/somepage.


      Is there a way around this?

        • 1. Re: Make a slider link to a root-relative or arbitrary URL?
          thetrickster888 Level 4

          What if you try using a URL that references your root... for instance in the URL field if you wanted mydomain.com/somepage just use "/somepage" or if you wanted mydomain.com/somefolder/somepage just use "/somefolder/somepage"

          • 2. Re: Make a slider link to a root-relative or arbitrary URL?
            NALambert Level 1

            Already tried it, as well as the other tricks like ../ and so on. It just appends exactly whatever I put into the URL field to 'mydomain.com/slider/', so if I put 'somepage' it links to mydomain.com/slider/somepage and if I put '/somepage' it links to mydomain.com/slider//somepage  (with two slashes).


            I could rename the slider's web app URL from 'slider' to 'pages' or something similar, then actually create a directory called 'pages' and move 'somepage', etc into this folder. It just is such a sloppy workaround.


            Also I am actually using AnythingSlider. It came with the BusinessCatalyst Adora template.

            • 3. Re: Make a slider link to a root-relative or arbitrary URL?
              thetrickster888 Level 4

              It looks like the template you are using uses Web Apps for the slider and the layout controlling that slider simply lists the {tag_image} and that tag wraps the URL of the web app detail view around the image.  There are two ways around this...


              The easiest, most hands-off way is to just add 301 redirects to the content you really want.  Let's say the slider links to "/slider/somepage" which is the detail view of the web app item but you want it to goto some other content instead...


              1. Just goto the BC Admin and goto Site Manager > URL Redirects and you'll want to add a 301 redirect from "/slider/somepage" to "/whatever-url-you-want" and it can be relative to the site root if you wish. 
              2. Once your redirects are in place, you can disable the detail views for the Carousel/Slider web app by going to Web Apps > Carousel (or Slider) > Edit Web App Settings and find the checkbox that says "Disable Detail View". 


              The caveat is that everytime you add a new slider you must add a 301 Redirect again but you don't have to muck with the web app layout much.  This additional step might be too much for a client to remember/do each time so there's another way.


              The second way is to add a new field to your Carousel Web App and to edit the layout of the Carousel List View to include the new URL field we add. 


              1. First, we'll add a new field to our Carousel web app- From the BC Admin goto Web Apps > Carousel > Edit Web App Settings
              2. Click the "Fields" tab on top of the screen
              3. Click "Add Field" button and for the name, let's use "ContentURL" (there's a default "URL" field for each web app item that defaults to the generated URL of the item-- we don't want that so we're creating another field to house the URL we really want to link to) When it asks for Field Type let's use "Text (String" and check the box for "Mandatory".  (Note: We're not using Text (Hyperlink) because of a limitation in BC Web Apps that we can't derive the value of the hyperlink just yet, instead it manually creates the full markup for the link which is no good for us since we need the carousel image inside our link)
              4. We've added the new field to our web app so next we'll be adding this field to our web app layout
              5. Click the "Develop" link on the top of the BC Admin - this will take us to the beta code editor to make edits (I stay away from making edits in the regular BC site/page editor since it sometimes strips code)
              6. In the "Files" panel on the left, navigate to Layouts > WebApps > Carousel and click the "list.html" file.  This is the layout for the list view which is used in your homepage site-wide template.
              7. If you used "ContentURL" as the new field name then you should just replace this:


                with this:

                <li><a href="{tag_contenturl}">{tag_image_nolink}</a></li>

              8. That's it. All set!  When you add values for the new field "ContentURL" you can use site-root relative urls like "/some-page" or you can use absolute URLs if you wish like "http://yoursite.com/some-page" but I think it's cleaner if you use relative URLs.
              9. If you decide to go this route and don't want to use the default item view for the Carousel web app items, follow the directions in the first example on how to disable the detail view from appearing in search results or on your sitemap.xml file.  And, going forward, make sure that each carousel has a "ContentURL" added to it so it link somewhere..


              Good luck. Let me know how it goes.