solved How to write an IF/ELSE Conditional Statement?

Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
I must have tried this 30 different ways.

What I'm looking for is an if, else statement that will delete something ONLY on the profile index page or include something ONLY on non profile index pages.

So within a certain skin I can let's say modify a div of the header template but only for the profile/index, not the other profile pages like profile/audio.

Something like:

 {if $current_url == '{$jamroom_URL}/{$profile_index}'}{else}{/if}

Maybe it should be more along the lines of:

{if template="$profile_index.tpl"}{else}{/if}





--

Ken Rich
indiegospel.net

updated by @ken-rich: 05/08/15 07:40:37PM
brian
@brian
9 years ago
10,148 posts
What template is this being added to?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
I'm trying to control two things.

Switch 2 CSS versions of the content div in header.tpl, and not include sidebar in profile_header.tpl but only for the index

The goal is to accomplish this transparency ( http://indiegospelradio.org) with removal of side column, but only on the profile index.

The name box and profile menu has been made visible ONLY to the profile owner and admins. If the non index sections (blog, pages, audio, etc.) otherwise looked and functioned normally, I could make a custom menu and truly have a site within a site.


--

Ken Rich
indiegospel.net

updated by @ken-rich: 03/26/15 06:02:34PM
michael
@michael
9 years ago
7,718 posts
Quote:
I must have tried this 30 different ways.

What I'm looking for is an if, else statement that will delete something ONLY on the profile index page or include something ONLY on non profile index pages.

So within a certain skin I can let's say modify a div of the header template but only for the profile/index, not the other profile pages like profile/audio.

Something like:

 {if $current_url == '{$jamroom_URL}/{$profile_index}'}{else}{/if}

Maybe it should be more along the lines of:

{if template="$profile_index.tpl"}{else}{/if}


Your not going to be able to use 1 if statement if it takes you 3 sentences to describe it. Its going to take you more than that.


If/else only checks for 1 thing at a time:

"if this is true (the thing to check), then show this part [ the stuff ] "

So if your English explanation is:
Quote:
...if, else statement that will delete something
What is the something, does it exist on the page or not. That could be the target of your first IF statement.
"if something exists on the page....."

That is ONE if statement there.

Then inside that you can have another.
Quote:
....ONLY on the profile index page...
"if the page is the profile index page....."
(but you would more than likely just include the statement in the profile_index.tpl so you know its the profile index page before you start, so don't need to check that.)
Quote: ...or....
This is a different thing, so handle it differently. Do one thing at a time.

You need to go about it one step at a time. Just slowly and methodically working towards the goal.
updated by @michael: 03/27/15 12:49:47AM
Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
I think the same if definition will work in both instances, but for simplicity let's focus on one.

I created a new CSS div id called #transparentcontent. It changes the background color of the content div from #F1F1F1 to transparent.

So in the header.tpl where the content div is defined, I want a conditional statement that will use transparentcontent on profile_index pages, and the content div on all others.

So something along these lines;

{if template="$profile_index.tpl"}<div id="transparentcontent">{else}<div id="content">{/if}



--

Ken Rich
indiegospel.net

updated by @ken-rich: 03/27/15 04:43:51PM
michael
@michael
9 years ago
7,718 posts
Ok, so
* in header.tpl where you want to use that IF statement put in {debug}
* clear the caches and visit the profile index page
* look for things in the popup window provided by debug for something that indicates that the page is the index for the profile.

Then use that variable in your IF
<div id="{if $profile_index == "profile index value"}transparentcontent{else}content{/if}">

updated by @michael: 03/27/15 11:55:06PM
michael
@michael
9 years ago
7,718 posts
Actually, a better way, is, if you want that transparent for all of the profile pages, then set it in the profile_header.tpl file.

So in elastic,
/skins/jrElastic/profile_header.tpl
looks like this:
{jrCore_include template="header.tpl"}

<div class="container">

    <div class="row">
        <div class="col12 last">
            <div class="profile_name_box">
.....

What you can do is set a value before the header is included, so that value is available in header.tpl, like this:
{$transparent = "on"}
{jrCore_include template="header.tpl"}

<div class="container">

    <div class="row">
        <div class="col12 last">
            <div class="profile_name_box">
....

Since $transparent is set before header.tpl is included, it will be available inside header.tpl.

From there, you can use it like this:
<div id="{if $transparent == "on"}transparentcontent{else}content{/if}">

and transparent will be on for all things that use the profile_header.
Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
I've tried both of these methods without success.

The problem appears to be a lack of exclusivity.

In other words, I can make the background transparent on the profile_index, but that also makes the content background transparent for every page in that profile (ie, timeline, audio, blogs, etc.)


--

Ken Rich
indiegospel.net
michael
@michael
9 years ago
7,718 posts
Quote: ....I can make the background transparent on the profile_index, but that also makes the content background transparent for every page in that profile (ie, timeline, audio, blogs, etc.)...
Right, that's what I thought you were after.

Looking at the {debug} these options change in that area. So putting this in the profile_header.tpl seams to work to output just on the profile index page:
{if $_post.module == "" && $_post.option == ""}
    THIS IS THE INDEX PAGE
{/if}

So you could use that to set the background to transparent


{if $_post.module == "" && $_post.option == ""}
    {$transparent = "on"}
{/if}

updated by @michael: 04/02/15 02:02:23AM
Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
I finally had a chance to test this - it works. That's what I was looking for. I've used it to isolate the side column removal to just the profile index as well.

When I look at the debug - I don't understand what I'm looking at, so $_post.module and $_post.option didn't stand out to me as anything useful.

I'll have to study this more (when I get time) to understand exactly what they mean, and why you knew they were useful for this conditional statement.

However, it does the job I need it to do, and that's what's important in the short term. Thanks very much.


--

Ken Rich
indiegospel.net
michael
@michael
9 years ago
7,718 posts
I've updated {debug} doc page with more info.

"{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/development/1477/debug
Ken Rich
Ken Rich
@ken-rich
9 years ago
926 posts
Thanks - that should make my studies more fruitful.


--

Ken Rich
indiegospel.net