Support community for TTG plugins and products.
NOTICE
The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.
This forum is now closed, and exists here as a read-only archive.
You are not logged in.
I use the Yoast plugin for my WordPress site. It has many features I use.
Backlight adds Google Analytics tracking code. This is a global setting.
The photo pages created by Backlight are unknown to WordPress, so Yoast never touches them.
When I create my WP theme in Backlight, it added the tracking code. But this means it's being added twice now, since Yoast also inserts it.
Is there a way to suppress the GA tracking code in the theme templates? Is this something I could do with PHP Plugins? If so, i'd need a clue.
EDIT: Opps, I'm typing faster than my brain this morning. Yoast no longer inserts the GA tracking code. I have another WP plugin that shows me basic analytics and it inserts the tracking code. Still, the question remains if there's a way to suppress Backlight from adding it to the WordPress templates.
I double checked this morning, and tried using the example {LUA=...} below taken from the documentation page. It causes LR to hang. Then before I publish anything again, I have to restart LR. I'm using the latest LR Classic.
{LUA=if Artist ~= "" then return sprintf("Copyright %s", Artist) end}Here's my workaround for the moment. I create a caption is one if missing.
{Caption|"Untitled"} - {Month} {YYYY}With the above, if there is no caption then the output is "Untitled - May 2015". I hate "untitled" as a title, but I'll live with it till the bug is fixed. This avoids output such as " - May 2015"
Using the LUA code execution option worked in the CE4 galleries. I tired it in Backlight, but found it caused LR to hang during publish. A little bit of LUA script was useful.
Consider the following example:
{Caption} - {Month} {YYYY}If the image doesn't have a caption, then the figure in the presentation page will display " - May 2015" instead of "My Photo - May 2015"
I had been using the following code in CE4.
{LUA=
if Caption ~= ""
then
return sprintf("%s - %s %s", Caption, Month, YYYY)
else
return sprintf("%s %s", Month, YYYY)
end
}The real issue is that there isn't a way to squelch (hide) " - " if the {Caption} is empty. Maybe there's another way?
The only "jump" I saw when I tested the change was when, in portrait mode, the browser's bottom toolbar popped in and out of existence, causing the document height to change.
I suspect it's got something to do with the size/aspect ratio of the image.
What was the pixel height and width of the image you used? I'd like to crop my image to that and try it.
It seems to be better (fixed?) while in landscape.
Nope, still happens. It's happening less often but not fixed.
It's obvious when it happens because the top of my background image is more light than the bottom. When the scaling bug happens, the background jumps from light to dark when scrolling down, and then dark to light when scrolling up.
BTW - because my background image isn't uniform, I can't use repeat to create a tile effect.
That said, I just realized I can make it less obvious by having a similar brightness across the entire image. The subtle randomness of the background will mostly go unnoticed when it moves, but at least it wrong jump up and down in brightness.
I think this does what you want.
Ha! Yes, thank you. Exactly what I was trying to do ![]()
I was so close so many times, but never got the selector and filter right.
we can actually achieve the intended behavior this way
I've added {background-attachment: scroll} to my CSS. I haven't seen any bad side effects, but I'm still seeing the background jump. It happens while scrolling in portrait mode. It seems to be better (fixed?) while in landscape.
The behavior seems to be scrolling is causing the background image to be scaled wider. I'm guessing the viewport is getting changed causing the background to scale wider, making it look like the background has jumped.
Interesting to note that in the wider landscape mode it's not being re-scaled while scrolling. Seems to be linked to the narrow width of portrait mode.
I couldn't find how to monitor the viewport, which I suspect it getting changed during scrolling. I've spent too much time looking at this. I've found it's been an iOS bug forever, across every release from Apple. Makes me sad to see such an obvious glitch in Apple's visual design.
I found a bug.
In the Background Setup of the Page Template, you can set the Background-position X to "top | center | bottom." It's the horizontal coordinate. It should be Left | Center | Right.
I noticed the invalid CSS while looking at another problem. Which leads me to what I think is another bug, but not sure if this is an iOS bug or if Backlight can work around it.
Normally the background image is fixed in its position and the album thumbs scroll over top the image.
I found on the iPhone scrolling a page is causing the background image to jump. Starting at the top it looks right. Then scrolling the nav off the top and stop, the background image moves. Sometimes it takes another touch. Scroll from the top to the middle should cause it to jump. Scroll from the top to the bottom and you should certainly see it.
I tried adding my own CSS to the body tag but then the iPhone seems to ignore the "fixed" attribute.
Searching the 'tubes I find this is a common complaint. Is this an iPhone bug?
Potential fixes (dated)
https://stackoverflow.com/questions/160 … und-on-ios
https://24b6.net/2012/12/17/ios-and-fixed-backgrounds
http://blog.dotlaunch.com/2015/04/fixed … oblem.html
I haven't coded with jQuery before, and only read a few things to get me started. After some hacking I found the code below is working. That is, it highlights the currently selected sub-menu under Photos and then the parent menu Photos.
The <current_page_item> class is being added to the <a tag>.
I'd much prefer the <current_page_item> class was added to <li> tag. Then it would match the behavior of WordPress, and my CSS would be consistent.
After continuing to hack away, I'm not getting any closer.
BTW One of the odd things I can't explain is how <current_page_item> is added to the parent menu when the sub-menu is selected. I suspect that's another clue to my problem.
Menu structure created by Backlight
<ul class="primary-menu menu mouseable">
<li class="menu-item"><a href="/">Home</a></li>
...
<li class="menu-item menu-item-has-children"><a href="/photos/">Photography</a>
<ul class="sub-menu">
<li class="menu-item"><a href="/photos/01-slug/">Item A</a></li>
<li class="menu-item"><a href="/photos/03-slug/">Item B</a></li>
<li class="menu-item"><a href="/photos/04-slug/">Item C</a></li>
<li class="menu-item"><a href="/photos/about-my-photography/">About</a></li>
</ul>
</li>
</ul>Script added to PHP Plugins
function ttg_scripts( $style, $path ) {
echo <<<SCRIPT
<script>
$(function() {
$("ul.menu a[href='" + window.location.pathname + "']").parentsUntil('menu-item-has-children').children('a').addClass('current_page_item');
});
</script>
SCRIPT;
} // ENDThanks Rod. Jim, do you have a site where we can see how my version of the code is behaving oddly?
Thanks Ben. I have my staging site at a point now where I can have you look at it. It's mostly dummy content (it's about me, a dummy). It's 85% done. The core structure and functionality are stable. I'm still working on the CSS and a few other details.
I don't want my staging site picked up by search engines or some crawler. You can reconstruct this URL. stage dot reekes dot net to see the staging site.
This is a Backlight created WordPress theme. All of menus are controlled by WordPress, except the Photography menu. Everything under Photography is Backlight (and thus PHP Plugins).
When WordPress selects a menu, it add the <current_page_item> class to the <li> menu item. All you have to do in WordPress is define the CSS for <current_page_item>.
The PHP script targets the <a> tag of the URL link, within the <li> menu. So the CSS is different. Here's how I defined it so I pick up both cases.
a.current_page_item, .current_page_item a {
background-color: rgba(150, 150, 150, 0.5) !important;
}For the Backlight (Photography) menu I'm using the function you shared. The only change I made was to use the <current_page_item> class.
function ttg_scripts( $style, $path ) {
echo <<<SCRIPT
<script>
$(function() {
$("ul.menu a[href='" + window.location.pathname + "']").addClass("current_page_item").parents('li').children().addClass('current_page_item');
});
</script>
SCRIPT;
} // ENDIf you go to the site you'll find that the WordPress menus are working as expected. But when I choose the Photography menu, or any of its sub menus, every menu gets highlighted.
I haven't looked at debugging the PHP. This is an area of the code I'm not familiar with. Hopefully you'll quickly find a solution.
You could try adding a priority to your filter - a higher number would make it run later, and so more likely to "win".
Even brute force doesn't seem to do the trick. I added this to my child theme's functions.php
add_filter( 'wp_default_editor', create_function('', 'return "tinymce";'), 1 );I was thinking I could remove the builtin filter, but Backlight adds the filter without using a function name so I can't remove it. I can alter the original code in the parent theme, and that works until I update a template. Since I'm in the middle of creating the theme it's getting instantly overwritten.
Not only do they work, but I have endeavored to make Backlight's themes child-theme-friendly. For example, most functions do a "function_exists" check, allowing child themes to overwrite them. Though not the one we're discussing.
Got the child theme setup. Added the set_default_editor to functions.php, but that's not working.
Seems the default is still set to 'html' by the parent theme. I didn't see a way to remove that filter, or how to override it.
Without understanding it, I can verify that there is something in the .htaccess file that's causing the 404. I simply renamed it, and reloaded the page. Then the URL works. I should have thought to test that in the first place.
At least I know where to look next. I'll guess it's going to be some assumption by the hosting server "knowing" where WordPress files are, and preventing access to other areas.
Then again, on second thought, does Backlight install/modify the .htaccess file within the galleries directory?
BTW - Backlight is turning out to be awesome. I've been using TTG plugins since the very first release. I put off upgrading to Backlight until I moved my site to a new hosting service. I also added SSL and the new sever includes a more rigorous .htaccess.
Have you tried creating a child theme per the WordPress codex?
I've created them in the past but haven't tried it for Backlight. I wasn't sure it would work.
The Backlight doc page for this MIA.
http://backlight.theturninggate.net/doc … ild_themes
Has anyone done this?
Backlight can sort by Title or Slug, but trying to create a user defined sort order isn't possible without prefixing slugs with a number.
To get the sort order I'd like I have to create slugs like this:
01-this
02-that
03-the-other-thing
04-one-more-thing
Taking a cue from WordPress, pages have a "order" field. That's used to create a primary sort order.
I'd love to see Backlight include an order field. This way we are free to create titles and slugs of any text, and still sort by the order field.
I hazard to guess you have enough structure in the LR/Backlight database to include the order field, and then query that order field in the Album Set to then order it accordingly.
I know this has been an issue for years. I was hoping it was addressed in Backlight.
Did you re-export the theme to Wordpress after making the change?
D'oh!
Looking at the /inc/theme_admin.php just now I see it had been reset back to the original "opinionated" filter LOL
What I just confirmed is changing a template in Backlight is over-writing the theme_admin.php as well. So changing that file isn't going to work.
That brings up another more general point I was going to ask about.
Is it possible to create a child theme, so Backlight doesn't over-write things like the above?
This also becomes an issue when updating Backlight. Usually I have a child theme and will be safe to change functions.php or other files within the theme.
An exported theme should have two identifying classes on the BODY tag.
That's what I would have expected. In my page template I use only within Backlight, I added the identifier "photo-page" and in the CSS I find the class <template-identifier-photo-page> for all pages associated with that template.
I have a cloned page template with minor differences I use for the Wordpress theme. This is the page template associated with the Wordpress theme add-on. It exports into Wordpress and everything seems fine, except for the missing identifier.
In that Wordpress page template I added the identifier "wordpress-page". When that gets exported into the Wordpress theme, it loses the identifier. Seems that the identifier is ignore when exporting a page template to Wordpress.
Examining the Home page the BODY tag contains only the following:
<home page-template-default page page-id-11 logged-in pangolin type-theme slug-backlight-theme>
The other pages created by Wordpress are the same, minus the "home" class.
I would have expected to find <template-identifier-wordpress-page> in the BODY of each page created by WordPress. Maybe exported page templates are not suppose to include the identifier. It seems like a bug, so I wanted to report this.
Still, I found I can use the <slug-backlight-theme> class for CSS overrides that are specific to WordPress pages.
I've tried relative paths and the entire https:// path in the Menu Set URL.
Here's another clue. Even when I'm in WordPress and I've got the About page open in the editor. If I click on View Page (the page that's actually in WordPress) even the generates a 404.
Really strange.
If I click on view the "dummy" Photos page in WordPress, that goes to the /photos URL and the content from Backllight is shown. This is the URL defined in WordPress and the actual page is blank.
That happens to be the location for Backlight, so the Backlight contents from LightRoom and and the Backlight templates all do the right thing.
It's just the About page I created in WordPress as a child of Photos that isn't working. This URL generates a 404, even though that't exactly the URL WordPress reports at the permalink for the page.
https://mydomain.net/photos/about
Doesn't matter how I try to get to that URL (e.g. menu choice from Backlight, clicking view page in WordPress, or just entering it into the browser's address bar).
Something is strange. Backlight is causing that URL to generate a 404. I'm not sure how to temporarily disable Backlight just to confirm the URL actually is valid.
Something in the .htaccess file maybe? An interaction with my server? I'm at a loss. And I don't know how to re-create a simple page in Backlight without having Pages installed. Even then, I'm not sure that's going to work.
I came across an odd problem. Not sure how to proceed.
I have a Photos page managed entirely by Backlight. It contains 10 albums, and there's 10 menu items under the Pages menu. All of this is unknown to WordPress.
Next to that are my WordPress pages like Home, Bio, Contact, etc. All of that is managed by WordPress and unknown to Backlight. Still, the WordPress theme was generated by Backlight but that's as far as it goes.
All of this makes sense to me. Here's the problem I found.
I have a page About My Photography I created in WordPress. It's more than plain text. There's a Font Awesome icon, bullet lists of links, etc.
That page belongs under the Photos menu (which is managed by Backlight not WordPress).
The path <mydomain.net/photos/about-my-photography> creates a 404 error.
I have a dummy page in WordPress for Photos. As a child page I added the About My Photography. So if this were a purely WordPress environment, Photos and About My Photography would all work as expected. The About page is a sub-page and a sub-menu of Photos.
When I go to the Photos page, it's resolved by the Backlight code. But when I try going to the About sub-page, it's a 404 error.
The Photos menu (created by Backlight) does have the "right" URL mentioned above. It's just that that URL can't be found.
Is there a way to make this work?
Co I need to buy Pages just to get this one page?
I'm using Backlight with the WordPress Theme add on. I created my page template and that's now the theme I'm using in WordPress. Everything is coming along nicely. Great stuff!
All of my page (Home, Bio, Contact, etc) are WordPress pages. They're created and managed by WordPress.
There's one directory, Photos, and all of it's sub-directories are managed entirely by Backlight.
WordPress manages menus slightly differently than BackLight. I've just about worked out all of those details (e.g. you have to recreate all the menus in both places, and a few slight tweaks to the CSS to make it all match).
Here's a difference...
WordPress will automatically add a class <current_page_item> to the currently selected menu. That's nice, because you simply define the CSS and you've got the current menu highlighted.
To replicated this in Backlight, there's the code from Rob and Ben. This inserts the class <selected> into the currently selected menu managed by Backlight. The only change I made was to change the calls <selected> to <current_page_item> so it matches the CSS I have for the WordPress pages.
Rob's code works fine, but Ben's caused odd problems. I'm sure it works for Ben and everyone else. So here's what's maybe different for my environment.
All the menus and pages are managed by WordPress (and the Backlight theme), except my Photos menu. That is a page, plus has 10 page below that, created in LightRoom. The Photos menu has sub-menus for each of those pages (separate Albums under the main Photos page).
Rob's code always does "the right thing." It highlights the menu item I had selected including the current sub-menu.
Ben's code acts strangely. I've tried both his options including the alternate that would highlight the top level menu when a sub-menu was selected. It's so strange I gave up trying to figure out what's going wrong. It seems it might be functioning correctly (maybe) but the simple CSS is going badly. The menu items get the wrong or a strange mix of CSS. All I can say is it must be an interaction with WordPress, the Backlight theme, and Backlight itself.
I wish Rob's code has the same feature of Ben's, where a selected sub-menu under Photos, would highlight the top menu item Photos.
I guess I'm asking for a hint. How do I enhance Rob's code to highlight the parent menu (Photos) when one of it's sub-menus had been selected?
I think this is a bug.
I set the template-identifier property in the Backlight page template. That's working for the pages generated by Backlight and LightRoom.
I have another page template that's used to create my WordPress theme. I added a template-identifier to that template, but it's not being included in the WordPress theme.
For now I found I can work around this using the slug-backlight-theme class (which seems to be unique for the WordPress css and doesn't appear in the Backlight css).
Nope, that change still has the editor being forced to html/text.
I just deleted the wp_default_editor filter. At least for now it behaves as I'm used to. I know it will get wiped out with the next update.
This would be a good custom option for the theme. So far I see only "google analytics, as set in Backlight" is the only setting. Adding a few more there like the editor preference would be nice.
My intention was to have the Text editor as default.
I'll add your change and see how it works, then let you know.
I understand your intent of always using the text editor. I think people using WordPress are used to how it normally behaves. A change in the behavior just shows up as "broken."
If you didn't alter the behavior, it works for you since WP will "remember" your preference.
I use both the visual and the text editor. It also works for me since I'm always jumping back and forth, and I'm expecting it to be how it was last time. I even go the extra mile and customize the WP admin css so my visual editor looks close to the actual page.
This is strange. When I'm using the WordPress theme created by my Backlight configuration, the page/post editor view is always forced to text.
I can change the theme to the builtin Twenty SixteenVersion and this doesn't happen.
Normally, if you are editing a page and switch to visual it stays visual. Even when you leave that edit, and then open a new page to edit. It will open in visual mode. So by default WordPress will keep your last setting.
But with the Backlight theme I'm finding it's always being forced to text view. I can change it to visual, and then after updating the page it's switches back to text again.
no integration with WordPress
I'm not clear what this means, but it sounds like Backlight is not an option for me. I need to add my photo gallaries to my existing WordPress site. I did this using the PHP Plugins to add my site's navigation and custom CSS so the TTG's look matched.
How can stand-alone albums "fit right in" if I can't have my sites existing menus/navigation integrated?
Today I have my WordPress site include a menu for Photos. That page is generated by the TTG Plugins. I have TTG navigation and header disabled. The TTG Plugins simply generate the pages content, within a simple wrapper I created using the PHP Plugin.
Are you saying this isn't possible? Sounds like you're saying Blacklight creates it's own navigation menus, and going from my existing site to the Blacklight page would be like going to a different web site.
Any more details on how to integrate Backlight with an existing WordPress site?