Jump to content

IoanaFriedman

Member
  • Posts

    6
  • Joined

  • Last visited

Posts posted by IoanaFriedman

  1. 7 minutes ago, creedon said:

    I have an idea. The code does take a bit of time to run. So the "header" shows first then the code replaces it. I should be able to address the issue with some CSS that initially hides the "header" and then after the code replaces the text, it will show the "header". It may take a second for the "header" to pop but at least it won't show the "header" text before it has been replaced.

    Thanks Tom, that makes total sense. I really appreciate all your help. If it's easy and quick enough on your end to adjust the code, I'll happily accept it. But I wouldn't want to cause you too much work.

  2. On 2/12/2021 at 11:37 PM, creedon said:

    Add the following to Blog Settings > Advanced > Page Header Code Injection for the blog page.

    
    <script>
    
      $( ( ) => {
      
        /*
        
          begin replace blog "header" text with category and/or tag
          
          the blog "header" in this case is a page section added above a normal blog
          page with single text block
          
          SS Version : 7.1
          
          */
          
          const replaceWithCategory = true;
          
          const replaceWithTag = false;
          
          // do not inlcude # at the beginning
          
          const textBlockId = 'block-7ee69d4a0268ec23d3ed';
          
          const categoryPrefixText = '';
          
          const categorySuffixText = '';
          
          const tagPrefixText = '';
          
          const tagSuffixText = '';
          
          // do not change anything below, there be the borg here
          
          const c = 'category';
          const pathname = location.pathname;
          const t = 'tag';
          
          const textBlockSelector = '#' + textBlockId +
          
            ' > .sqs-block-content > *:first';
            
          let conditions = [ ];
          
          if ( replaceWithCategory ) conditions.push ( c );
          
          if ( replaceWithTag ) conditions.push ( t );
          
          if ( ! conditions.some ( e => pathname.includes ( '/' + e + '/' ) ) )
          
            return;
            
          const ct = pathname
          
            .split ( '/' ) [ 2 ]
            
            .replaceAll ( '/', '' );
            
          let prefixText, suffixText;
          
          switch ( ct ) {
          
            case c :
            
              prefixText = categoryPrefixText;
              
              suffixText = categorySuffixText;
              
              break;
              
            case t :
            
              prefixText = tagPrefixText;
              
              suffixText = tagSuffixText;
              
              break;
              
            }
            
          const text = prefixText +
          
            pathname
            
              .split ( '/' ) [ 3 ]
              
              .replaceAll ( '+', ' ' ) +
              
            suffixText;
            
          $( textBlockSelector ).text ( text );
          
          } );
          
          // end replace blog "header" text with category and/or tag
          
      </script>

    This is for a v7.1 site and specific to the OP's needs.

    Let us know how it goes.

    A million thank yous! This works 🙂

    The general blog header shows us for a split second, then gets replaced with the filtered category. Do you know why that may be happening?

    Thank you again,

    Ioana

  3. On 8/26/2020 at 4:35 PM, acid__bat said:

    Site URL: https://spinach-tarantula-nbae.squarespace.com/

    When I filter blog posts by author or category in 7.1, there's no visual indication of what page I'm on.

    7.0 used to include text indicating what filtered results you're looking at. Something like "Posts by Author X."

    Is there any way to add that  back in? 

    Hi @acid__bat, have you discovered a solution for this? I'm having the same issue with the category filter. 

  4. Site URL: https://www.thedaring.co/blog/category/Art

    Hi everyone,

    In Squarespace 7.1, when a reader clicks a category link (screenshot attached), I'd like them to see that category text at the top of the filtered list of content they're served. Right now, they are seeing the general blog header (screenshot attached), which can be disorienting.

    Has anyone figured out a way to do this?

    Many thanks,

    Ioana

    Blog category page.png

    Blog post page.png

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.