Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi guys, I'm working with a website that is basically finished...i just need a stupid thing....

i have some cloned pages this is the code:

Code: Select all
<div id="projectsleftpanel">
  <table width="33%" border="0" cellpadding="0px" style="font-size:13px; float:right;">
  <cms:pages masterpage='projects.php' limit='9' orderby='publish_date'>
  <tr height="23px">
   <td><a style="text-decoration:none; color:#999; text-align:right;" href="<cms:show k_page_link />"><cms:show k_page_title /></a></td>
  </tr>
  </cms:pages>
  </table>
  <table width="33%" border="0" cellpadding="0px" style="font-size:13px; float:right;">
  <cms:pages masterpage='projects.php' limit='9' offset='9' orderby='publish_date'>
  <tr height="23px">
   <td><a style="text-decoration:none; color:#999; text-align:right;" href="<cms:show k_page_link />"><cms:show k_page_title /></a></td>
  </tr>
  </cms:pages>
  </table>
  <table width="33%" border="0" cellpadding="0px" style="font-size:13px; float:right;">
  <cms:pages masterpage='projects.php' limit='9' offset='18' orderby='publish_date'>
  <tr height="23px">
   <td><a style="text-decoration:none; color:#999; text-align:right;" href="<cms:show k_page_link />"><cms:show k_page_title /></a></td>
  </tr>
  </cms:pages>
  </table>
     

</div>

puts the coned pages titles in a table.....now i need just to change the color of the page i'm on....
i know sounds stupid but i can't figure it out...

anybody can help me?

thanks in advance i really appreciate....
Hi,

.....now i need just to change the color of the page i'm on....

Pardon me if I understood wrong, but changing the page's color has nothing to do with the code you posted.
That can be done using plain CSS styles e.g. body{ background-color:#000; } etc.

Once again, if I got your question wrong, kindly excuse me and rephrase the question a bit.
Thanks.
Lol sorry I was in a rush.. The color of the link...
All those links have color #999 as you can see...
I have to change the color if I am on the page...
Those links generated are like a menu and I need to change the color of the current page link.. Does it make sense?!?
Thanks a lot...
OK, I get it now -

The following code should do it
Code: Select all
<cms:set current_page=k_page_name />
<div id="projectsleftpanel">
   <table width="33%" border="0" cellpadding="0px" style="font-size:13px; float:right;">
      <cms:pages masterpage='projects.php' limit='9' orderby='publish_date'>
         <cms:if k_page_name=current_page >
            <cms:set link_color='#ff0000' />
         <cms:else />
            <cms:set link_color='#999' />
         </cms:if>
         
         <tr height="23px">
         <td><a style="text-decoration:none; color:<cms:show link_color />; text-align:right;" href="<cms:show k_page_link />"><cms:show k_page_title /></a></td>
         </tr>
      </cms:pages>
   </table>
   
   <table width="33%" border="0" cellpadding="0px" style="font-size:13px; float:right;">
      <cms:pages masterpage='projects.php' limit='9' offset='9' orderby='publish_date'>
         <cms:if k_page_name=current_page >
            <cms:set link_color='#ff0000' />
         <cms:else />
            <cms:set link_color='#999' />
         </cms:if>
         
         <tr height="23px">
         <td><a style="text-decoration:none; color:<cms:show link_color />; text-align:right;" href="<cms:show k_page_link />"><cms:show k_page_title /></a></td>
         </tr>
      </cms:pages>
   </table>
   
   <table width="33%" border="0" cellpadding="0px" style="font-size:13px; float:right;">
      <cms:pages masterpage='projects.php' limit='9' offset='18' orderby='publish_date'>
         <cms:if k_page_name=current_page >
            <cms:set link_color='#ff0000' />
         <cms:else />
            <cms:set link_color='#999' />
         </cms:if>
         
         <tr height="23px">
         <td><a style="text-decoration:none; color:<cms:show link_color />; text-align:right;" href="<cms:show k_page_link />"><cms:show k_page_title /></a></td>
         </tr>
      </cms:pages>
   </table>
</div>

A bit of explanation -
Your original code is using three 'pages' loop hence the solution had to be duplicated thrice. Otherwise it is pretty straightforward.

Before we enter any of the 'pages' loop, we save the name of the current page we are on in a separate variable because within the 'pages' loop 'k_page_name' will change to the pages being enumerated-
Code: Select all
<cms:set current_page=k_page_name />

Within the 'pages' loop, as we go through each of the pages we compare the name of the page being enumerated with the variable we saved in the first step above (i.e. name of the main page).
If the two match, we set 'link_color' to #ff000, else we set it to the default #999
Code: Select all
         <cms:if k_page_name=current_page >
            <cms:set link_color='#ff0000' />
         <cms:else />
            <cms:set link_color='#999' />
         </cms:if>

Finally we use the 'link_color' to set the color
Code: Select all
<a style="text-decoration:none; color:<cms:show link_color />; ...


Hope this helps. Please let me know.
4 posts Page 1 of 1

Who is online

In total there are 3 users online :: 0 registered, 1 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests