New Webhosting Page with Statamic

New Webhosting Page with Statamic

The goal is to recreate the new Colocation Homepage in / with Statamic exactly as it is given in Zeplin: https://zpl.io/NEBvzY4

This project is very similar to one i’ve done recently which was to create the new colocation page with Statamic. The only difference is the content & the layout. Which is also why the process and the way i went about it was very similar if not identical at times. So here i also firstly created all the necessary Statamic blueprints and elements i required. Which were the following:

  • The webhosting page blueprint
  • A new collection for the offers
  • A new blueprint for the offers
  • Conversion of globals to fieldsets
  • Desired content for the webshoting page
  • Desired content for the offers

The first thing i did is create a new collection for the offers. I decided to do this first because i will need to be able to access the offers in the webhosting blueprint. The one special thing about the offers are that sometimes there will be a discount for an offer and needs to be displayed accordingly where you have to be able to set the discounted price and until when said discount will last. I decided to converse with Manuel on what he thinks is the best way to go about doing this. After the exchange i reached a conclusion on how to do it which was to just create a text & date field to then later check if its filled and add the necessary design changed compared to a normal offer.
After the blueprint was done i created the 4 entries in the collection for each offer one entry.

With the offers done i went ahead and created a new blueprint for the webhosting page. For that i went with the same setup as the colocation page, put everything in a replicator field and split the content into different sets / sections. Around mid-way through i noticed that the support card that i need is a global but since i need to be able to use it inside other blueprints i require it to be a fieldset. So to continue i first had to convert the globals i had (the 2 different support / contact cards) into fieldsets. Now there were 2 ways to go about this, the first one is the easy one, it to just recreate the global as a fieldset and then delete the respective global and the second way was to manipulate or well edit the files directly and convert the globals to fieldsets so. I decided to go for the second option because to be quite frank i didn’t want to create new blueprints since i didn’t wish to do the work twice.
For that i had to go into the respective “.yaml” files move them and change the “designation” in that sense and also remove the markdown files which were created from the blueprints. With them converted i went back to the webhosting blueprint and finished that. Now all that was left is to fill in the desired content into the page and with that done, i completed the Statamic part of this project. Here are the different sets:

Information:

Blueprint:

Company:

Blueprint:

Selected Offers:

Blueprint:

Trust Reason:

Blueprint:

Contact:

Blueprint:

Comments:

Blueprint:

With all the Statamic parts done its once more time for the code. I started here with a simple layout where i could see & test if all the elements are bound to Statamic correctly as well. After confirming that everything’s able to be displayed i went and refined the layout to make it look accordingly as to what is given in Zeplin. A good few elements were similar to what i’ve done or used for the colocation page so i was able to use those as a reference to assist me. With that the curve at the bottom or the image gradient that i struggled with before were much easier to do. I still encountered some slight problems with the image gradients but i was able to deal with them in a somewhat swift manner.

A new problem that arose with this part was in the selected offers set. As mentioned before the discount offer is to be displayed differently to the normal one, it has a red border with a banner at the top and the price is different. The problem with that is that it changes the dimensions of the card which caused for the cards to collide in the mobile views or just shift the card a bit so it wasn’t properly aligned with the others offers anymore. I thought of 3 different ways to achieve the desired result. One was to make a border and then add a div at the top that disappears behind the card to make it seem to have a smooth transition, the second was similar but instead for the div at the top to disappear behind is to bend it ( like a concave lense) is so it connects perfectly to the top of the offers and the third one is to create a div that is slightly larger than the offer card (with the banner at the top) and put the offer card inside said div. Now i was thinking of proceeding with either option 1 or 3 because option 2 is just a more difficult version of option1 or not even possible with a bend because of the dimensions of option 1.
I decided that i would converse with Manuel again to see which option he thinks is the best or if perhaps one of them aligns with what he used in his project where he did this. As it turns out he was familiar with both options and option 3 is very similar to what he used himself, so i decided that i would try both and see which works better. I opted to try option 1 first because its one that i had a bit less faith in and noticed a problem during experimenting beforehand that will most likely appear with this option. I was able to make it work so it aligns correctly and doesn’t collide with the other offer cards in the mobile views. But the problem which i mentioned before appeared and that was that there was a color mismatch with the div and the border even though they had the exact same coloring. I do not know why that was the case and neither did Manuel so with that i proceeded with option 3. After implementing that the same problem occurred again with the collision but i was able to fix that after a bit.

PHP
{{ collection:offers sort="offer_price:asc" }}
    {{ if discount_offer_price }}
        <div class="relative mt-8 min-h-[520px] rounded-[12px] bg-[#dc0046] md:mt-0 md:h-full">
            <div class="absolute inset-x-0 top-[-32px] -z-10 flex h-[44px] items-start justify-center rounded-t-[12px] bg-[#dc0046] px-4 pt-1.5 text-center text-[13px] font-bold text-white">
                Aktion bis {{ discount_date format="d.m.Y" }}
            </div>
  
            <article class="relative mb-[2px] ml-[2px] mr-[2px] flex min-h-[518px] flex-col rounded-b-[10px] rounded-t-[12px] bg-white p-6 text-[#111118] md:h-[calc(100%-2px)]">
    {{ else }}
        <article class="relative flex min-h-[520px] flex-col rounded-[12px] border border-[#e7e8ef] bg-white p-6 text-[#111118] md:h-          full">
    {{ /if }}
PHP
<div class="mt-8">
    {{ if discount_offer_price }}
        <p class="-mt-5 text-[13px] text-[#8b8f9b] line-through">{{ offer_price }} {{ currency }} / Mt.</p>
        <div class="flex items-end gap-1">
            <p class="text-[34px] font-bold leading-none">{{ discount_offer_price }}</p>
            <p class="text-[12px] text-[#6e7080]">{{ currency }} / Mt.</p>
        </div>
    {{ else }}
        <div class="flex items-end gap-1">
            <p class="text-[34px] font-bold leading-none">{{ offer_price }}</p>
            <p class="text-[12px] text-[#6e7080]">{{ currency }} / Mt.</p>
        </div>
    {{ /if }}
</div>

Tags: