Jump to content

[SOLVED] Can't find a way to preserve a form-value in a Joomla-component


Recommended Posts

Hello,

 

First - I am a complete noob at PHP and HTML, and that's why I'm stuck!!

 

I'm trying to make a slight modification to a Joomla component called "Chordbase". What it does, is the ability to have a database of songs - with song lyrics and guitar/piano chords shown. It shows a list of songs (by name), and by clicking a songname - it displays the songlyrics (with chordnames above the songtext).

 

Now; I'm adding an extra functionality to Chordbase. The function I'm trying to make - is to have the chords shown below the song, as chord-images. By the help of a dropdown-box (select-box), one can choose between one of these:

- dont show chord-images

- show guitar chord images

- show piano chord images

 

I've gotten so far where I it actually works - in sense of that I can choose i.e. "Show guitar chords" and press the "Update" button (behind the select-box). Then, the chords ARE shown below the song!! The trouble comes when I press "Printer friendly".... I will come back to that in a minute!

 

Most of the "action" going on in this Joomla-component, is divided into these php-scripts:

 

chordbase.php    (the "main" program)

 

chordbase.html.php  (makes the top-screenpart of the songview - where it gives a "menu" with different options,

                            like "Printer friendly" or "Edit song".... and so on...  IT'S HERE I ADDED MY DROPDOWN-BOX).

 

song.class.php  (displays the songtext / chordnames.  IT'S IN HERE I ADDED THE CODE TO DISPLAY

                        CHORD-IMAGES).

 

In a function called  "function songHeader" in "Chordbase.html.php" I've added the code like this:

 

 

<form action="index.php?option=com_chordbase&Itemid=<?php echo $Itemid ?>&task=viewSong&song_id=<?php echo $song_id ?>&pop="0"" method="post">
<select name="showchords">

   <option value="dontshow" >Don't show chords</option>
   <option value="showguitar">Show guitar chords</option>
   <option value="showpiano">Show piano chords</option> -->

<input type="submit" name="submit" value="Update">
</select>

 

 

So far, so good.... BUT  --- and here's a HUGE trauma (yes, I'm almost going nuts here):

-> When I choose "Printer friendly" and the song shows up in a new window- the chords are gone!!

 

I've so far found out this:

When I select "Printer friendly" - ALL variables I'm using for checking whether chords are going to be shown or not - they are RESET (null-value).

 

I've added the variable $_POST['showchords'] in function "song.class.php" to check/evaluate if the chord-images are going to be shown (it's in this function I've added some programming to show the chord-images). Each time "Printer friendly" is called - this variable is EMPTY.

 

Another thing (this is maybe one major reason for this problem):

- usually, when the song itself is shown - it calls up Joomla's "index.php" - i.e. like this:

[code:1]index.php?option=com_chordbase&Itemid=<?php echo $Itemid ?>&task=viewSong&song_id=<?php echo $song_id ?>&pop="0"[/code:1]
But, when "Printer friendly" is called - Chordbase does this by calling Joomla's "index2.php", like this:
<?php echo $mosConfig_live_site ?>/index2.php?option=com_chordbase&Itemid=<?php echo $Itemid ?>&task=viewSong&showChords=<?php echo $showChords == "no"?"no":"yes" ?>&song_id=<?php echo $song_id ?>&pop=1" target="_blank">Printer friendly</a>]

--> this code is located in "chordbase.html.php" (as one of the menu-choices).

 

So, I assume that because of the different approach of calling the function for showing the song (in "song.class.php") - it looses all knowledge of the content of this variable i mentioned further above...

How to deal with this - is far, far  beyond my knowledge and skills :(

 

 

HOW in the world can I get it to REMEMBER that I chose "Show guitar chords" when I select "Printer friendly"??

 

I've tried absolutely "everything" my ignorant mind could find on the internet (Google)...

 

- koda

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.