3 years ago
Topic

Hi there!
I need to create a Wishlist and a Comparelist that is saved in the session.

I was wondering if the feature "Persistent Search" can be used to achieve to have the Wishlist and Compare Items stored somewhere.

but where and how is the persistent search stored? I did not find any entries in the cookies or storage?

Thanks a lot!

Get a VIP membership
4229 Posts
Kadministrator
3 years ago
3
Level 1

In joomla you have this thing called session storage - ooly id is in a cookie, the rest of data is stored in the database. To get wish list or compare list you would need custom code that would store this data in session storage.

1279 Posts
Bucklash
3 years ago
2
Level 2

I use session to compare values beforerender and afterstore

might be helpful...

BeforeRender:

// Make end strings in to array
// e.g. $cckMap['start']['11th_fret'] = array;
$cckMap['start']['lesson_files'] = explode(',', $fields['choose_lesson_files']->value);
$cckMap['start']['external_link'] = explode(',', $fields['choose_external_link']->value); 
$cckMap['start']['11th_fret'] = explode(',', $fields['choose_11th_frets']->value);
$cckMap['start']['skills_concepts'] = explode(',', $fields['choose_skills_concepts']->value);
$cckMap['start']['bands_artists'] = explode(',', $fields['choose_bands_and_artists']->value);


$session = JFactory::getSession();
$session->set('cck_map', $cckMap);

AfterStore

//SESSION
// Get a handle to the Joomla! application object
$application = JFactory::getApplication();
$session = JFactory::getSession();
$cckMap = $session->get('cck_map'); // the array of initial values


// Make end strings in to array
// e.g. $cckMap['end']['blog_types'] = array;
$cckMap['end']['lesson_files'] = explode(',', $fields['choose_lesson_files']->value);
$cckMap['end']['external_link'] = explode(',', $fields['choose_external_link']->value); 
$cckMap['end']['11th_fret'] = explode(',', $fields['choose_11th_frets']->value);
$cckMap['end']['skills_concepts'] = explode(',', $fields['choose_skills_concepts']->value);
$cckMap['end']['bands_artists'] = explode(',', $fields['choose_bands_and_artists']->value);

// $cckMap['end']['lesson_files'] = array()
$cckMap['cck'] = $fields['cck_value']-> live_value;


// CLEAN ARRAYS (remove duplicates)
foreach ($cckMap['start'] as $k => $v) 
{
	$cckMap['start'][$k] = array_filter($v);
}
foreach ($cckMap['end'] as $k => $v) 
{
	$cckMap['end'][$k] = array_filter($v);
}

// do stuff.....

Jon

3 years ago
1
Level 3

Hello and thank you!
So when I have a button "add to wishlist" and use your code... What does trigger the code? I don't get it yet.

Thanks

1279 Posts
Bucklash
3 years ago
0
Level 4

Hi

I was just showing session stuff really.

I was going to do a bookmark thing a little while back:

  1. In content view show 'bookmark' form via form field or module.
  2. In bookmark form, using beforerender do db search to see if content is bookmarked
  3. if content is not bookmarked already, show save button
  4. If content is already bookmarked, show delete button. 

Bookmark being a content type that stores id of content and user id.

But that is as far as I got. Sidetracked and all that.

Is that what you would do?

3 years ago
0
Level 1

So I solved it now by saving the items in localStorage. Quite niceeeee and Happy about the result - database is a good option too, but i don't have a user login for that page .... :)

4229 Posts
Kadministrator
3 years ago
0
Level 1

Notice: I deleted spammer's comment and another comment related to it.

Get a Book for SEBLOD