Add block URL to database
Permalink
Hi Ok, i want to be able to link to a block from a second block source source.
I want to add the block url to the database when creating the block, i.e.
I want a field (already setup) linkID to be added that draws the following: DIR_REL/$pageID#$bID
I have already set the block when printing to add the $bID anchor, just need to be able to pull the URL from the database... anyone know how i'd do this?
Thanks
Ben
I want to add the block url to the database when creating the block, i.e.
I want a field (already setup) linkID to be added that draws the following: DIR_REL/$pageID#$bID
I have already set the block when printing to add the $bID anchor, just need to be able to pull the URL from the database... anyone know how i'd do this?
Thanks
Ben
I don't get what your trying to do...
ok, it's quite hard to describe, i'm using eantics biography block, and basically this allows you to create small bios, then had a second block elsewhere that shows a list of all the bios.
I want to add a link to this list that links back to the original bio. On the bio view block ive added:
to the top of each block, so effectively you can navigate to that specific block by going...http://www.url.com/test-page#67... for example where 67 is the block id.
When the contact list is created it pulls all the details from each block and creates the list, so when you edit the original block i need a way of saving its url to the database also (ideally in a hidden field) so i can pull this out and create a link:
Ideally i guess it would be even better if I could just get the code at this point to pull the block parentpageID and block id, but i thought that seemed even more complicated!
Thanks for your help in advance.
Regards
Ben
I want to add a link to this list that links back to the original bio. On the bio view block ive added:
<a name="<?php echo $bID; ?>"></a>
When the contact list is created it pulls all the details from each block and creates the list, so when you edit the original block i need a way of saving its url to the database also (ideally in a hidden field) so i can pull this out and create a link:
$output .= '<tr><th><a href="'.$link.'">'.$name.'</a></th>';
Ideally i guess it would be even better if I could just get the code at this point to pull the block parentpageID and block id, but i thought that seemed even more complicated!
Thanks for your help in advance.
Regards
Ben
Hi Ben and the others!
I think I have the same plan..
I have made a block wich places a image gallery on one page:
http://raetus.demicomp.ch/index.php/referenzen/installation/...
I the block editor form, the user can check a box to indicate, if that block should be shown on the "Homepage"..
And on the "Homepage" (http://raetus.demicomp.ch/) I need to put "teasers" with a link to that page and gallery (this block just outputs all the image galleries wich have that flag set in the db). When a user clicks that link, she/he will jump to the page with that gallery and scroll down to the gallery and open it.
Ok,...
the only problem I have is to save the page url into database when placing the image gallery block. (so, I know where/ on which page the gallery is)
Or does somebody have another solution?
I think I have the same plan..
I have made a block wich places a image gallery on one page:
http://raetus.demicomp.ch/index.php/referenzen/installation/...
I the block editor form, the user can check a box to indicate, if that block should be shown on the "Homepage"..
And on the "Homepage" (http://raetus.demicomp.ch/) I need to put "teasers" with a link to that page and gallery (this block just outputs all the image galleries wich have that flag set in the db). When a user clicks that link, she/he will jump to the page with that gallery and scroll down to the gallery and open it.
Ok,...
the only problem I have is to save the page url into database when placing the image gallery block. (so, I know where/ on which page the gallery is)
Or does somebody have another solution?
hi grorog, that is a fantastic idea i'd love to use that block ;-) however i was never able to progress what i did further as i didn't have the expertise and no one was able to offer a solution, i hope you fair better... i'll keep an eye on this post. Regards, Ben
somewhere I've read that I can get the "parent collection" of a block, but I don't know where..
Is it possible to get the page path of where the block is placed on, when I have the BlockID? that would make it, I think..
Or is there an approach for exactly solving such ideas?
Is it possible to get the page path of where the block is placed on, when I have the BlockID? that would make it, I think..
Or is there an approach for exactly solving such ideas?
In my experience, this is the wrong approach to take. Blocks are intended to be put on any page and you should not rely on them ever existing in one specific location.
Instead, what I've found is that Concrete5 revolves around pages. Pages are the "atomic unit of information" (or something like that). You should always try to set up your site so that content is added to pages (via blocks), but then you display content from the page and link to the page -- regardless of which blocks are on it or not. Now, usually you will have a standard set of blocks on a certain kind of page, and you can use the Page Defaults to make this easier for people entering new data.
But the advantage to having "one page represents one record in a database" or "one page represents one person" or "one page represents one photo gallery" is that you can now use the Page List block to display that info anywhere else on the site. (Another advantage is that the site search will work better because there's a specific destination page for that content in the search results. Also this helps SEO to have a unique and relevant URL for each record of content).
Learning to customize the page list block with custom templates is incredibly useful. You can start off with the free "Page List Teasers" addon from the marketplace, which pulls content directly from a page (instead of just displaying the "description" property). And if you want to do further customizations, I have a great boilerplate custom template that is much easier to understand and customize than the built-in page list template. It also contains a bunch of comments showing how to retrieve various pieces of data from the page:
https://github.com/jordanlev/c5_clean_block_templates...
(in the files list, click "page_list", then "view.php", then click the little "raw" link at the top-right of the code and you'll see it in plain text, then you can just save that as "view.php" and drop it into YOURSITE/blocks/page_list/ )
Hope that helps.
-Jordan
Instead, what I've found is that Concrete5 revolves around pages. Pages are the "atomic unit of information" (or something like that). You should always try to set up your site so that content is added to pages (via blocks), but then you display content from the page and link to the page -- regardless of which blocks are on it or not. Now, usually you will have a standard set of blocks on a certain kind of page, and you can use the Page Defaults to make this easier for people entering new data.
But the advantage to having "one page represents one record in a database" or "one page represents one person" or "one page represents one photo gallery" is that you can now use the Page List block to display that info anywhere else on the site. (Another advantage is that the site search will work better because there's a specific destination page for that content in the search results. Also this helps SEO to have a unique and relevant URL for each record of content).
Learning to customize the page list block with custom templates is incredibly useful. You can start off with the free "Page List Teasers" addon from the marketplace, which pulls content directly from a page (instead of just displaying the "description" property). And if you want to do further customizations, I have a great boilerplate custom template that is much easier to understand and customize than the built-in page list template. It also contains a bunch of comments showing how to retrieve various pieces of data from the page:
https://github.com/jordanlev/c5_clean_block_templates...
(in the files list, click "page_list", then "view.php", then click the little "raw" link at the top-right of the code and you'll see it in plain text, then you can just save that as "view.php" and drop it into YOURSITE/blocks/page_list/ )
Hope that helps.
-Jordan
Dear jordanlev, thank you very much for that info.
I'd like to do that as you describe to do with "pages". But I'm sorry, could you please give me another kick start, how I can do this with my website design (http://raetus.demicomp.ch/index.php/referenzen/installation/). There are more than one gallery on a website. And I can not change that, because I have to implement what the designer wants..
I'd like to do that as you describe to do with "pages". But I'm sorry, could you please give me another kick start, how I can do this with my website design (http://raetus.demicomp.ch/index.php/referenzen/installation/). There are more than one gallery on a website. And I can not change that, because I have to implement what the designer wants..
I see that there are several image galleries on that page. I assume each one is a different block. And the problem is you want to be able to show those image galleries on other pages without the user having to enter them again, correct?
Why don't you just copy one of the blocks to the scrapbook and paste it on the other page you want to display it on? And if you need to be able to edit the galleries and have the changes appear everywhere, you could put the gallery in the global scrapbook.
But if all you really need is some code to determine the page that the block is on, you can use this (in the block controller.php file):
Why don't you just copy one of the blocks to the scrapbook and paste it on the other page you want to display it on? And if you need to be able to edit the galleries and have the changes appear everywhere, you could put the gallery in the global scrapbook.
But if all you really need is some code to determine the page that the block is on, you can use this (in the block controller.php file):
$blockPageUrl = View::url($this->getCollectionObject()->getCollectionPath());