Kit the Human 759 Share Posted January 25, 2019 <!-- BUILD Array --> {{if $character->fields('rotate1')}} <!-- ALL THE IMAGES --> <!-- IMAGE ONE --> {{$string = ''.$character->fields('rotate1').'';}} {{$avrotate1 = explode('"',strstr($string,'https://'))[0];}} <!-- END ONE --> {{endif}} {{if $character->fields('rotate2')}} <!-- IMAGE TWO --> {{$string = ''.$character->fields('rotate2').'';}} {{$avrotate2 = explode('"',strstr($string,'https://'))[0];}} <!-- END TWO --> {{endif}} <!-- IMAGE THREE --> {{if $character->fields('rotate3')}} {{$string = ''.$character->fields('rotate3').'';}} {{$avrotate3 = explode('"',strstr($string,'https://'))[0];}} {{endif}} <!-- END THREE --> <!-- RANDOM--> {{if $character->fields('rotate1')}} {{$charimages = array("{$avrotate2}", "{$avrotate1}", "{$avrotate3}");}} {{$random_av = array_rand($charimages);}} {{endif}} <!-- END RANDOM --> <!-- END array --> <li class='cAuthorPane_photo'> <a href="{$character->url()}"> <span class="ipsUserPhoto ipsUserPhoto_large"> {{if $character->fields('rotate1')}} <!-- ROTATOR --> <img src="{$charimages[$random_av]}" id="rotatorav" alt="{$character->name}"> <!-- END ROTATOR --> {{elseif $avatar = $character->avatar()}} <img src="{$avatar->url}" alt="{$character->name}"> {{else}} <img src='{resource="default_photo.png" app="core" location="global"}' alt="{$character->name}"> {{endif}} </span> </a> </li> So a couple of questions on this. First, it works! But: 1. Is that the cleanest way to do that? 2. Why doesn't {$avatar->url} work in the random array? I can't tell what it's returning, but inspect element just has src(unknown) in it. 3. I tried to write an else statement for the third avatar. If $character->fields('rotate3' is empty, then $avrotate3 is $avrotate1. That worked....but it wrote the URL beneath every avatar on that page, even when $character->fields('rotate1') was empty. Any ideas? Thanks in advance! PSI: an Occult Investigations RP Roleplay Architects: Grab a friend (or many friends!) and just write. You can also find me at: Link to comment Share on other sites More sharing options...
Admin Morrigan 1,826 Admin Share Posted January 25, 2019 Seems fine to me although I would possibly change the logic up a little for the checks for a rotator image to like {{if $avrotate1 || $avrotate2 || $avrotate3}} as this should check to see if any of those fields exist to build your array. There is no $avatar->url it would be $characacter->avatar()->url I think (I’m on my phone but can double check when I’m on my pc). The if statement should already do the work for you as far as verifying if the third avatar exists or not. Is it not doing that? Profile set made by myself and original Artwork by Fae Merriman, my daughter. Link to comment Share on other sites More sharing options...
Kit the Human 759 Author Share Posted January 26, 2019 Thanks Morr! $characacter->avatar()->url and other guesses isn't doing much for me. In the character's authorpane it has {{elseif $avatar = $character->avatar()}} <img src="{$avatar->url}" alt="{$character->name}"> {{else}} which is why I thought I could simply use the avatar->url thing. character->avatar doesn't do anything for me either. Or character_avatar...but I think that's just a row in the database table so. The if statement I have works. I'm looking for an else because the array gets all of the rotator images whether or not there's anything in it. So avrotate3 should equal avrotate1 if nothing has been uploaded. PSI: an Occult Investigations RP Roleplay Architects: Grab a friend (or many friends!) and just write. You can also find me at: Link to comment Share on other sites More sharing options...
Admin Morrigan 1,826 Admin Share Posted January 26, 2019 Okay for the else statement this is because regardless if there is an upload it's returning something. If you just print the variable (you don't have to use print_r) it will show you what it's returning for each. Can you tell me what those are? For the former (the rotate image ones) they are probably returning the code with the first part of your uploads in it so like everything but it prints "https://yourdomain.com/uploads/" without a file after it. So most likely you'll need to perform the stripping of the variable FIRST then in your if statement use {{if $newvariable != "UPLOAD URL"}} Add the thing to the array.{{endif}} For the avatar I would have to verify what it returns first. Profile set made by myself and original Artwork by Fae Merriman, my daughter. Link to comment Share on other sites More sharing options...
Kit the Human 759 Author Share Posted January 26, 2019 else statement...lol of course. I've wrapped the whole thing in an if the first avatar has a thing and now it works. I can't make heads nor tails of if statements in arrays. For the avatar {$character->avatar} //returns monthly_2019_01/rich.png.a7f611e6838575b045a12ebe3aacf939.png So I need to get it to put the my domain in there PSI: an Occult Investigations RP Roleplay Architects: Grab a friend (or many friends!) and just write. You can also find me at: Link to comment Share on other sites More sharing options...
Admin Morrigan 1,826 Admin Share Posted January 26, 2019 {file="$variable"} should work. Profile set made by myself and original Artwork by Fae Merriman, my daughter. Link to comment Share on other sites More sharing options...
Kit the Human 759 Author Share Posted January 26, 2019 For the punters at home {{$zero = \IPS\File::get( 'core_theme', $character->avatar)->url;}} Will make $zero the URL of the normal avatar, which I can then add to the array. I'll be putting this in the IPS coterie for those who might want rotating avatars as well! But this can be marked solved now. PSI: an Occult Investigations RP Roleplay Architects: Grab a friend (or many friends!) and just write. You can also find me at: Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now