check if image is in a set
Permalink
hi i am trying to make a package to output a sortable gallery.
like this demo:http://mixitup.io/demos/cards
i know how to output images from one set in a loop e.g.:
<?php foreach ($images as $img): ?>
<?php echo $img->large->src; ?>
<?php endforeach; ?>
but i think i will have to put my images in more than one set to be able to sort them. (like the demo link)
does any one know a way of asking if a file belongs to a set?
then output the sets name inside the loop?
am just looking for the code to do this.
thank you.
like this demo:http://mixitup.io/demos/cards
i know how to output images from one set in a loop e.g.:
<?php foreach ($images as $img): ?>
<?php echo $img->large->src; ?>
<?php endforeach; ?>
but i think i will have to put my images in more than one set to be able to sort them. (like the demo link)
does any one know a way of asking if a file belongs to a set?
then output the sets name inside the loop?
am just looking for the code to do this.
thank you.
![Blenderite](/files/avatars/162092.jpg)
Why exactly can't you just use MixItUp? It looks like it would work with C5.
because i want to make it dynamically pull in images that the user has uploaded through the file manager. and then sort by multiple file sets.
Hi Chris,
Try this:
Try this:
<?php foreach ($images as $img): ?> <?php echo $img->large->src; ?> <?php // get the file ID of your image $fileIdToCheck = $img->getFileId(); // I assume your code will already have a file set ID to check against $fileSetIdToCheck = 1; // or use $fileSetIdToCheck = FileSet::getByName('my file set name'); // using the file set ID, get a file set object $fileSetObj = FileSet::getById($fileSetIdToCheck); // get the file set name from the file set object $fileSetName = $fileSetObj->getFileSetName(); // Get a file object $fileObj = File::getById($fileIdToCheck); // get an array of the file sets associated with that file
Viewing 15 lines of 24 lines. View entire code block.
sorry been away.
i try the code but its hard to get to work how i want.
what i have is one major file set that all the images are in then the images are also added to some other file sets. so i am looping through the jajor file set and trying to ask what set each image belongs to. each image belongs to two sets so i need to echo out the second set:
i can see the second sets name in the array below called fsName.
the major file set is called mixItUpMaster and the set am trying to target is what ever is in the second fsName in this case its 960.
how can i grab the second fsName from the array?
i used print_r($thisFilesFileSetsArray);
and got:
(
[0] => FileSet Object
(
[fileSetFiles:protected] =>
[_dbat] => 1
[_table] => FileSets
[_tableat] => FileSets
[_where] =>
[_saved] => 1
[_lasterr] =>
[_original] => Array
(
[0] => 2
[1] => mixItUpMaster
[2] => 1
[3] => 1
[4] => 0
)
[foreignName] => fileset
[fsID] => 2
[fsName] => mixItUpMaster
[uID] => 1
[fsType] => 1
[fsOverrideGlobalPermissions] => 0
)
[1] => FileSet Object
(
[fileSetFiles:protected] =>
[_dbat] => 1
[_table] => FileSets
[_tableat] => FileSets
[_where] =>
[_saved] => 1
[_lasterr] =>
[_original] => Array
(
[0] => 3
[1] => 960
[2] => 1
[3] => 1
[4] => 0
)
[foreignName] => fileset
[fsID] => 3
[fsName] => 960
[uID] => 1
[fsType] => 1
[fsOverrideGlobalPermissions] => 0
)
)
i try the code but its hard to get to work how i want.
what i have is one major file set that all the images are in then the images are also added to some other file sets. so i am looping through the jajor file set and trying to ask what set each image belongs to. each image belongs to two sets so i need to echo out the second set:
i can see the second sets name in the array below called fsName.
the major file set is called mixItUpMaster and the set am trying to target is what ever is in the second fsName in this case its 960.
how can i grab the second fsName from the array?
i used print_r($thisFilesFileSetsArray);
and got:
(
[0] => FileSet Object
(
[fileSetFiles:protected] =>
[_dbat] => 1
[_table] => FileSets
[_tableat] => FileSets
[_where] =>
[_saved] => 1
[_lasterr] =>
[_original] => Array
(
[0] => 2
[1] => mixItUpMaster
[2] => 1
[3] => 1
[4] => 0
)
[foreignName] => fileset
[fsID] => 2
[fsName] => mixItUpMaster
[uID] => 1
[fsType] => 1
[fsOverrideGlobalPermissions] => 0
)
[1] => FileSet Object
(
[fileSetFiles:protected] =>
[_dbat] => 1
[_table] => FileSets
[_tableat] => FileSets
[_where] =>
[_saved] => 1
[_lasterr] =>
[_original] => Array
(
[0] => 3
[1] => 960
[2] => 1
[3] => 1
[4] => 0
)
[foreignName] => fileset
[fsID] => 3
[fsName] => 960
[uID] => 1
[fsType] => 1
[fsOverrideGlobalPermissions] => 0
)
)