• Resolved burridge

    (@burridge)


    First of all, very cool plugin – I’m excited about the possibilities it opens.

    I’m wondering if you can advise on a good way to do the following:
    I am trying to set up a page that displays an image (in a blox block) in the genesis_after_header hook, with the page or post title text layered over the image, like it is in this theme demo (not StudioPress, obviously): http://demo.qodeinteractive.com/bridge122/

    Is there a good way to do this with Blox? Everything I have tried has resulted in two separate sets of divs within genesis_after_header – one for the image and one for the title – so they display one above the other. I have tried setting the image both as a background and not, and I’ve tried pulling in the text both through the functons.php file (moving the post title to genesis_after_header) and through a second block on the post. Both display one above the other.

    Is there a really good, elegant way to do this that I’m just not thinking of?

    https://ww.wp.xz.cn/plugins/blox-lite/

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Nick Diego

    (@ndiego)

    Blox is the solution for everything 😉

    But in all seriousness, let me look into this. I am sure I can get you a solution. I have a few in mind, but it is all about coming up with the easiest for you to manage. You could do this with the image widget and use the caption field for the page/post title, but you would have to manually type in the title, which I am guessing is not ideal.

    Do you want the image to have the parallax effect that it does in the link you provided? That is another degree of difficulty, but not impossible.

    Nick

    Thread Starter burridge

    (@burridge)

    Thanks for the speedy response! Parallax isn’t necessary – but the ability to have the text display the page title without having to type it in separately is important. It seems like it should be possible, but I couldn’t figure it out after several hours of fiddling (though I am somewhat new to this).

    If you come up with a solution, I’ll be hugely appreciative!

    Plugin Author Nick Diego

    (@ndiego)

    Morning burridge,

    So I have “half” of a solution for you. The other piece will come in the plugin update I have planned for this weekend.

    The best way to go about accomplishing this is to simply use the static image content option and modify the css on the image caption. In my test, I used a global block so I could target multiple pages, but this works for local blocks as well.

    Use the static image option, choose any image you want and make sure to check the “Set As Background” option. Enter in the page title in the caption. For my test, I did something like <h1>My Page Title</h1>. (I know manually typing the title is not ideal. This is the other “half” that I will address in the next update).

    Then on the style tab, in the “Custom Block CSS” section, add the following code:

    #blox_global_6 .blox-image-wrap {
    	display: table;
    	height: 500px; /* Adjust image container height as needed */
    }
    #blox_global_6 .blox-caption-container {
            display: table-cell;
    	position: static;
    	text-align: center;
            vertical-align: middle;
            width: 100%;
    }
    
    #blox_global_6 .blox-caption-wrap {
    	background: none !important;
    }
    
    @media only screen and (max-width: 480px) {
    	#blox_global_6 .blox-image-wrap {
    		height: 300px; /* Adjust as needed for mobile */
    	}
    }

    Note that wherever I have #blox_global_6 replace it with your block’s id. You may need to make some adjustment to the heights to get it to look the way you want, but the above code should get you most of the way there. I also included a media query to reduce the height of the image on mobile, but you could add more media queries for the different breakpoints on your site.

    You will also likely need to style the caption text to make it look the way you want. To do that, you can target the text with something like the following code. Note the <h1> is in there because that is what I wrapped my caption in. remove it if you don’t want it:

    #blox_global_6 .blox-caption-wrap h1 {
    	color: _____;
            font-size: ______;
            etc.
    }

    To address the issue of manually typing in the page title, I am going to be adding a number of shortcodes to the plugin, so all you would need to add is something like [page-title] to the caption box and it would automatically pull the caption. After reading your post, I realized that there is a bunch of information that would be handy if available via shortcode like the author name, the last time a page was updated, etc. So I will be adding these in the next release, which will likely be before the weekend is out.

    Anyway, I hope this helps and let me know if you have any questions on the CSS.

    Nick

    Thread Starter burridge

    (@burridge)

    Nick,

    You completely rock. The shortcodes thing is actually EXACTLY what I need. I can think of a lot of cool ways to use that feature beyond this example too.

    Thank you so much for the help!

    Plugin Author Nick Diego

    (@ndiego)

    Hey burridge, just released v1.1.0 which takes care of the “other half”. I will be building out the docs on the shortcodes tomorrow morning, but this is a start: https://www.bloxwp.com/documentation/shortcodes/.

    There are only 4 right now, but the one you will want is [blox-page-title]. Simply drop that into the caption and it will spit out the current page title. There are a few other attributes available in the shortcode, [blox-page-title before=”” after=”” singular_only=””]. I will be writing up what these do in the docs.

    Hope this helps!

    Thread Starter burridge

    (@burridge)

    Awesome, I will give it a shot over the weekend and report back (though I’m sure it will work great). Thank you!

    Thread Starter burridge

    (@burridge)

    So I tested it out over the weekend and overall it’s working great. I had trouble with the “display: table-cell;” line in the CSS above and ultimately had to take it out and settle for not being able to vertically center the caption text on the image (I’m sure it can be done, I just gave up because it looks fine at the bottom). Otherwise, though, this works fantastically. I REALLY appreciate you taking the time to address this and update the plugin! Thank you for a great product!

    Plugin Author Nick Diego

    (@ndiego)

    Hi burridge, I am glad it is working for you. If you want, post the link to your site here and I will see if I can provide additional CSS to make it vertically centered. That way you will at least have a solution if you want to implement it.

    Nick

    Thread Starter burridge

    (@burridge)

    Oh, I didn’t actually see your last message until now because I am not getting follow-up post emails for some reason. Anyway, thanks for the offer, but I am actually happy with how it is looking with the caption text aligned to the bottom.

    However, another related issue (sorry to keep having to come back to you with this stuff) – the page-title shortcode doesn’t seem to work on Archive/Category pages? Those are displaying the name of the most recent post title (on both the blog and a custom post type section I’ve got). Is there a different shortcode for these?

    Plugin Author Nick Diego

    (@ndiego)

    That actually is default behavior for the shortcodes. I updated the page about shortcodes on the site with this info: https://www.bloxwp.com/documentation/shortcodes/

    The shortcodes use the get_page_title() function in WordPress which only really works on singular pages. It exhibits some strange behavior on archive pages if used outside of the loop. If you set the attribute singular_only="true" the page title will not display on any non-singular pages. I am working on another shortcode which will print the title on archive pages. It will be in the next batch of shortcodes that are released. Probably early next week.

    Nick

    Thread Starter burridge

    (@burridge)

    Ah, got it. Okay, good to know. Thanks again for the speedy response!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Nesting blocks? Or is there another solution?’ is closed to new replies.