Jump to content

Find a page(s) by pagefile uploadName


Gideon So
 Share

Recommended Posts

@Gideon So I did a test and it works on my side with multiple files, but there's something strange, the first uploaded file always has empty filedata. If I delete all files and upload again it's the same. ? That looks like a bug.

image.thumb.png.8087e7032b4d44f260b6123f5e9c9d6a.png

Another way would be a hook to set filename into description field.

Link to comment
Share on other sites

If I got it right, you are looking for pages having a (page)file (in field "file_field") named like something?
Do you mean something like this...?

$fieldname = 'file'; // or 'file_field' for your case...?
$search = 'partofthename';

// V1 via api...
$pgs = $pages->find("{$fieldname}%={$search}");
foreach ($pgs as $p) {
    echo "{$p->id} {$p->title}<br>\n";
}

// V2 via database and api...
$pgids = array_column(
    $this->database->query("select `pages_id` from `field_{$fieldname}` where `data` like '%" . addslashes($search) . "%'")->fetchAll(PDO::FETCH_OBJ),
    "pages_id"
);
$pgs = $pages->find("id=" . ($pgids ? implode("|", $pgids) : "0"));
foreach ($pgs as $p) {
    echo "{$p->id} {$p->title}<br>\n";
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...