Let's say your portal relationship looks like this:
LayoutTable::_pkID = PortalTable::_fkID
Add another Tutorial: What are Table Occurrences? of the portal's table and link it in like this:
PortalTable|SelectedImage::_pkPortalTableID = LayoutTable::_fkSelectedImageID
Then a script, performed by a button in the portal row or the OnObjectEnter script trigger set on the portal can do this:
Set Field [LayoutTable::_fkSelectedImageID ; PortalTable::_pkPOrtalTableID ]
Then add your container field to the layout from PortalTable|SelectedImage.
Awesome. This is working great. Thanks! I got the image to switch when I switch portal rows. Now I'm still trying to figure out what hide condition will work so that the container field will only appear at all when I'm in the portal... Any ideas on that?
Have the same script set the value of a global variable such as $$ContainerVisible to 1.
Use a "hide object when" expression of: Not $$ContainerVisible
Use the inspector to give the container field an object name. (enter a name into the Name box).
After the set variable script step that sets $$ContainerVisible to 1, use Refresh Object to refresh this one layout object on your layout.
Ah ha. The "Refresh Objects" idea alone was the key. Now I have just set the Hide Condition to be Get ( ActivePortalRowNumber )< 1 and as long as my OnEnter script refreshes that object, it works. With the global variable method, it was harder to get the container to go away when I clicked back out of the portal. Thanks!
Ok. Still having some lingering issues. I am trying to get a bunch of objects to show up and be related to whatever portal row I'm in, but not be there when I'm not in the portal. The first part is working ok thanks to the refresh script step. But when I leave the portal, the script is not triggered since it's on "On Enter" so none of the objects realize I have left and they are still sitting there visible when they should be hidden. I tried to add an "On Exit" script too, but then navigation inside the portal becomes unbearably slow. Other ideas?
OnObjectExit and OnObjectEnter are triggers that are tripped as you enter and exit the portal row, not the portal as a whole as I recall. So I can see how there could be a "lag" as you move the focus from one portal row to the next as that will trip both triggers as you exit one portal and enter the next.
Hmmmm, can't think of any suggestions at this moment...
Thanks for the follow-up. I don't really understand how, but the container image is working correctly is disappearing when I click out of the portal. Everything else, though, isn't. And it all has the same "Get ( ActivePortalRowNumber )< 1" hide condition. I wonder what is different about the container that's making it work...
Depending on what you click, your "click outside the portal" may be committing records and this can enable things to update even without the Refresh Object step. Clicking the blank area of your layout will commit records. Clicking into another field will not.