Geen hotlink bij bepaalde text waarde
Op mijn forum portal heb ik een recruitment block waar we mensen laten weten wie of wat we nodig hebben.
Een klein voorbeeld van het block:
Hunter: Open
Warrior: Closed
Door op "Open" of "Closed" te klikken word de gebruiker doorverwezen naar een applicatie form.
Wat ik graag zou willen weten is dat wanneer er de tekst "Closed" staat dat dan de link niet clickable is, dus gewoon tekst word.
Is dit makelijk op te lossen dmv een if statement of komt hier meer bij kijken?
Met vriendelijke groet,
Bas
hoe ziet je code er nu uit? is gewoon een if else meer niet met in de if een link en in de else de tekst bijvoorbeeld.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
case 'recruitment':
$display_vars = array(
'title' => 'ACP_RECRUITMENT_SETTINGS',
'vars' => array(
'legend1' => 'ACP_RECRUITMENT_BLOCK_SETTINGS',
'portal_recruitment' => array('lang' => 'PORTAL_RECRUITMENT' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_recruitment_link' => array('lang' => 'PORTAL_RECRUITMENT_LINK' , 'validate' => 'string', 'type' => 'text:50:100', 'explain' => true),
'legend2' => 'PORTAL_RECRUITMENT_DISPLAY',
'portal_display_dk' => array('lang' => 'PORTAL_RECRUITMENT_DK_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_dru' => array('lang' => 'PORTAL_RECRUITMENT_DRU_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_hun' => array('lang' => 'PORTAL_RECRUITMENT_HUN_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_mag' => array('lang' => 'PORTAL_RECRUITMENT_MAG_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_pal' => array('lang' => 'PORTAL_RECRUITMENT_PAL_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_pri' => array('lang' => 'PORTAL_RECRUITMENT_PRI_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_rog' => array('lang' => 'PORTAL_RECRUITMENT_ROG_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_sha' => array('lang' => 'PORTAL_RECRUITMENT_SHA_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_lock' => array('lang' => 'PORTAL_RECRUITMENT_LOCK_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_war' => array('lang' => 'PORTAL_RECRUITMENT_WAR_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'legend3' => 'PORTAL_RECRUITMENT_STATUS_TEXT',
'portal_recruitment_death_knight' => array('lang' => 'PORTAL_RECRUITMENT_DEATH_KNIGHT' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_druid' => array('lang' => 'PORTAL_RECRUITMENT_DRUID' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_hunter' => array('lang' => 'PORTAL_RECRUITMENT_HUNTER' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_mage' => array('lang' => 'PORTAL_RECRUITMENT_MAGE' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_paladin' => array('lang' => 'PORTAL_RECRUITMENT_PALADIN' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_priest' => array('lang' => 'PORTAL_RECRUITMENT_PRIEST' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_rogue' => array('lang' => 'PORTAL_RECRUITMENT_ROGUE' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_shaman' => array('lang' => 'PORTAL_RECRUITMENT_SHAMAN' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_warlock' => array('lang' => 'PORTAL_RECRUITMENT_WARLOCK' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_warrior' => array('lang' => 'PORTAL_RECRUITMENT_WARRIOR' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'legend4' => 'PORTAL_RECRUITMENT_STATUS_TEXT_COLOR',
'portal_recruitment_font_dk' => array('lang' => 'PORTAL_RECRUITMENT_FONT_DK' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_dru' => array('lang' => 'PORTAL_RECRUITMENT_FONT_DRU' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_hun' => array('lang' => 'PORTAL_RECRUITMENT_FONT_HUN' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_mag' => array('lang' => 'PORTAL_RECRUITMENT_FONT_MAG' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_pal' => array('lang' => 'PORTAL_RECRUITMENT_FONT_PAL' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_pri' => array('lang' => 'PORTAL_RECRUITMENT_FONT_PRI' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_rog' => array('lang' => 'PORTAL_RECRUITMENT_FONT_ROG' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_sha' => array('lang' => 'PORTAL_RECRUITMENT_FONT_SHA' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_lock' => array('lang' => 'PORTAL_RECRUITMENT_FONT_LOCK' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_war' => array('lang' => 'PORTAL_RECRUITMENT_FONT_WAR' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'legend5' => 'Save',
)
);
break;
$display_vars = array(
'title' => 'ACP_RECRUITMENT_SETTINGS',
'vars' => array(
'legend1' => 'ACP_RECRUITMENT_BLOCK_SETTINGS',
'portal_recruitment' => array('lang' => 'PORTAL_RECRUITMENT' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'portal_recruitment_link' => array('lang' => 'PORTAL_RECRUITMENT_LINK' , 'validate' => 'string', 'type' => 'text:50:100', 'explain' => true),
'legend2' => 'PORTAL_RECRUITMENT_DISPLAY',
'portal_display_dk' => array('lang' => 'PORTAL_RECRUITMENT_DK_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_dru' => array('lang' => 'PORTAL_RECRUITMENT_DRU_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_hun' => array('lang' => 'PORTAL_RECRUITMENT_HUN_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_mag' => array('lang' => 'PORTAL_RECRUITMENT_MAG_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_pal' => array('lang' => 'PORTAL_RECRUITMENT_PAL_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_pri' => array('lang' => 'PORTAL_RECRUITMENT_PRI_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_rog' => array('lang' => 'PORTAL_RECRUITMENT_ROG_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_sha' => array('lang' => 'PORTAL_RECRUITMENT_SHA_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_lock' => array('lang' => 'PORTAL_RECRUITMENT_LOCK_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'portal_display_war' => array('lang' => 'PORTAL_RECRUITMENT_WAR_DISPLAY' , 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
'legend3' => 'PORTAL_RECRUITMENT_STATUS_TEXT',
'portal_recruitment_death_knight' => array('lang' => 'PORTAL_RECRUITMENT_DEATH_KNIGHT' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_druid' => array('lang' => 'PORTAL_RECRUITMENT_DRUID' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_hunter' => array('lang' => 'PORTAL_RECRUITMENT_HUNTER' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_mage' => array('lang' => 'PORTAL_RECRUITMENT_MAGE' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_paladin' => array('lang' => 'PORTAL_RECRUITMENT_PALADIN' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_priest' => array('lang' => 'PORTAL_RECRUITMENT_PRIEST' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_rogue' => array('lang' => 'PORTAL_RECRUITMENT_ROGUE' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_shaman' => array('lang' => 'PORTAL_RECRUITMENT_SHAMAN' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_warlock' => array('lang' => 'PORTAL_RECRUITMENT_WARLOCK' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'portal_recruitment_warrior' => array('lang' => 'PORTAL_RECRUITMENT_WARRIOR' , 'validate' => 'string', 'type' => 'text:12:12', 'explain' => false),
'legend4' => 'PORTAL_RECRUITMENT_STATUS_TEXT_COLOR',
'portal_recruitment_font_dk' => array('lang' => 'PORTAL_RECRUITMENT_FONT_DK' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_dru' => array('lang' => 'PORTAL_RECRUITMENT_FONT_DRU' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_hun' => array('lang' => 'PORTAL_RECRUITMENT_FONT_HUN' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_mag' => array('lang' => 'PORTAL_RECRUITMENT_FONT_MAG' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_pal' => array('lang' => 'PORTAL_RECRUITMENT_FONT_PAL' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_pri' => array('lang' => 'PORTAL_RECRUITMENT_FONT_PRI' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_rog' => array('lang' => 'PORTAL_RECRUITMENT_FONT_ROG' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_sha' => array('lang' => 'PORTAL_RECRUITMENT_FONT_SHA' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_lock' => array('lang' => 'PORTAL_RECRUITMENT_FONT_LOCK' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'portal_recruitment_font_war' => array('lang' => 'PORTAL_RECRUITMENT_FONT_WAR' , 'validate' => 'string', 'type' => 'text:6:6', 'explain' => false),
'legend5' => 'Save',
)
);
break;
Code (php)
1
2
3
4
5
6
7
2
3
4
5
6
7
<!-- IF S_DISPLAY_ROG -->
<tr>
<td class="row1" align="right" ><img src="{PORTAL_RECRUITMENT_IMAGE}rogue.png" width="18" height="18" alt="Rogue" /></td>
<td class="row1" align="left" ><div align="left"><span class="gensmall"> <b><font color="#dec800">Rogue</font></b></span></div></td>
<td class="row1" align="left" ><span class="gensmall"> <a href="{PORTAL_RECRUITMENT_LINK}"><font color="{PORTAL_RECRUITMENT_FONT_ROG}"><b>{PORTAL_RECRUITMENT_ROGUE}</b></font></a></span></td>
</tr>
<!-- ENDIF -->
<tr>
<td class="row1" align="right" ><img src="{PORTAL_RECRUITMENT_IMAGE}rogue.png" width="18" height="18" alt="Rogue" /></td>
<td class="row1" align="left" ><div align="left"><span class="gensmall"> <b><font color="#dec800">Rogue</font></b></span></div></td>
<td class="row1" align="left" ><span class="gensmall"> <a href="{PORTAL_RECRUITMENT_LINK}"><font color="{PORTAL_RECRUITMENT_FONT_ROG}"><b>{PORTAL_RECRUITMENT_ROGUE}</b></font></a></span></td>
</tr>
<!-- ENDIF -->
Code (php)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
<?php
function recruitment_link($link, $status){
echo ($status == 'open') ? '<a href="'.$link.'">Open</a>' : 'Closed' ;
}
?>
function recruitment_link($link, $status){
echo ($status == 'open') ? '<a href="'.$link.'">Open</a>' : 'Closed' ;
}
?>
Gewijzigd op 16/05/2010 12:47:07 door - Mark -
Het woord "Open" zou ook anders kunnen zijn bv. "2 warriors".
Zou dit ook een optie kunnen zijn?
Dit stukje code is aangepast van w3schools
Code (php)
Ik weet alleen niet goed wat er bij $d=date("D"); zou moeten staan.
Gewijzigd op 16/05/2010 13:00:33 door B Martens
date() zal nooit de string 'Closed' komen.
Je kan de functie van Mark Coenen heel makkelijk aanpassen:
Verander ($status == 'open') in ($status != 'Closed') en je hebt het gewenste resultaat.
Eerst stond er
Als status is 'open' dan link weergeven
nu staat er
Als status is niet 'closed' dan link weergeven.
Waar je date("D") vandaan haalt weet ik niet, maar uit de functie Je kan de functie van Mark Coenen heel makkelijk aanpassen:
Verander ($status == 'open') in ($status != 'Closed') en je hebt het gewenste resultaat.
Eerst stond er
Als status is 'open' dan link weergeven
nu staat er
Als status is niet 'closed' dan link weergeven.
Gewijzigd op 16/05/2010 13:12:18 door Raymond ---
Het stukje code met date("D") is een aangepast stukje code van w3schools om text weer te geven aan de hand van een bepaalde dag in de week.
Ik had dat stukje code gebruikt als basis.
Maar ik zal de code van Mark Coenen is testen en het resultaat hier posten.