Use DomDocument on/off
- Boris
-
Topic Author
- Offline
- New Member
-
Less
More
- Posts: 5
- Thank you received: 0
1 year 4 months ago - 1 year 4 months ago #1
by Boris
Use DomDocument on/off was created by Boris
Hey you!
In case within the plugin the option 'Use DomDocument' is set to 'off' - which is necassary to avoid unwished add-buttons,
the buttons via {msl_button} doesn't get the values via CustomBlocks – only the straight way.
How to solve this one?
• in this certain project I am only using articles to add on the list via {msl_button}
• we always use within the article the definend selectors from CustomBlock
This is working great – except that other articles also show the add-button where it is not usefull for us.
Just let me know.
Best,
Boris
EDIT:
It seems to me that the option 'Auto Include Add to Favorites Button' within the settings for a custom block makes no difference – the button is always there.
As we need to have the header of an article (and the article-img as well), I set the container to .com-content-article which works great … except ... ^^
In case within the plugin the option 'Use DomDocument' is set to 'off' - which is necassary to avoid unwished add-buttons,
the buttons via {msl_button} doesn't get the values via CustomBlocks – only the straight way.
How to solve this one?
• in this certain project I am only using articles to add on the list via {msl_button}
• we always use within the article the definend selectors from CustomBlock
This is working great – except that other articles also show the add-button where it is not usefull for us.
Just let me know.
Best,
Boris
EDIT:
It seems to me that the option 'Auto Include Add to Favorites Button' within the settings for a custom block makes no difference – the button is always there.
As we need to have the header of an article (and the article-img as well), I set the container to .com-content-article which works great … except ... ^^
Last edit: 1 year 4 months ago by Boris. Reason: Additional
Please Log in or Create an account to join the conversation.
- Christopher Mavros
-
- Offline
- Administrator
-
1 year 4 months ago #2
by Christopher Mavros
Christopher Mavros
me@mavxr.com
If you like our extensions, please rate us on the JED!
Replied by Christopher Mavros on topic Use DomDocument on/off
Hello Boris,
Custom Blocks are only necessary if you want to add parts of an article, or your page in your list.
(E.g. In a gallery page with multiple photos, and no way to distinguish them, you can use Custom Blocks to add a photo to your favorites)
If you want to add Joomla articles to your list, you can use Custom Blocks to add the button, but you have to explain to MyShortlist how to identify them.
If the selectors you use are only found in a single-article page, you can set the "Use Current URL as Item Link" option to "Yes", so that MyShortlist identifies the active article using the URL.
If your selectors are found in a category page, where multiple articles are supposed to have their own buttons, you should provide a Link Selector, pointing to the article's link (<a> element), so that MyShortlist uses the href attribute of the link to reverse-route the URL and identify the actual Joomla article.
Use DomDocument can be set to Off, if you use Custom Blocks to add Joomla articles to your lists. It is only required if you want to add parts of your website to your lists.
Currently, and given from your other post as well, I believe that you are unintentionally adding parts of your Joomla article (the title and image) as custom blocks, instead of having the actual article identified with a link selector. The latter is strongly recommended, unless you have an otherwise unknown good reason.
Assuming that you only want the {msl_button} to appear in a certain category of articles, you have the following options:
1. You may use some category-specific CSS selectors in your Custom Block. You can add a Page Class in your respective menu items, and change your selector to .my-page-class .com-content-article
2. You may differentiate the category's HTML, or even add the button directly, by creating a template override or a separate layout for this category.
3. You may write {msl_button aid="1"} where 1 is the article ID you want to add. Note that you can place such a button anywhere in your site, and it will add the Joomla article with ID 1 in your list.
Let me elaborate on point 2.
I believe the simplest way to go is to write {msl_button aid="<?php print $this->item->id; ?>"} somewhere in your article code, probably with a template override.
Since you want this to be category specific, you can write a simple PHP check to see if this is the category you want, like so:
There's also a less hacky way, but it requires a more complex configuration.
Let's assume you want to have a different layout for the single-article page of all articles of category A. You can copy the files components/com_content/tmpl/article/default.php and components/com_content/tmpl/article/default.xml in your templates/your-template/html/com_content/ directory and rename them to mylayout.php and mylayout.xml accordingly. Open the XML file and in line 3 change the layout title attribute to something else, like "My Layout".
Then you can open the PHP file and place the button by writing {msl_button aid="<?php print $this->item->id; ?>"}.
In your category, you can select this new layout as the "Layout" under the Options tab.
I understand this is a lot, so feel free to ask any questions you may have.
As a side note, and for future readers:
If you have multiple lists, you can even write {msl_button aid="1" cp="listprefix"} where listprefix is your List ID (Cookie Prefix) from your module options.
If you want to add items of other components, you can write {msl_button aid="#vm#1"} where #vm#1 stands for Virtuemart Item with ID 1. See our two letter code table for all supported components .
Thanks again!
Custom Blocks are only necessary if you want to add parts of an article, or your page in your list.
(E.g. In a gallery page with multiple photos, and no way to distinguish them, you can use Custom Blocks to add a photo to your favorites)
If you want to add Joomla articles to your list, you can use Custom Blocks to add the button, but you have to explain to MyShortlist how to identify them.
If the selectors you use are only found in a single-article page, you can set the "Use Current URL as Item Link" option to "Yes", so that MyShortlist identifies the active article using the URL.
If your selectors are found in a category page, where multiple articles are supposed to have their own buttons, you should provide a Link Selector, pointing to the article's link (<a> element), so that MyShortlist uses the href attribute of the link to reverse-route the URL and identify the actual Joomla article.
Use DomDocument can be set to Off, if you use Custom Blocks to add Joomla articles to your lists. It is only required if you want to add parts of your website to your lists.
Currently, and given from your other post as well, I believe that you are unintentionally adding parts of your Joomla article (the title and image) as custom blocks, instead of having the actual article identified with a link selector. The latter is strongly recommended, unless you have an otherwise unknown good reason.
Assuming that you only want the {msl_button} to appear in a certain category of articles, you have the following options:
1. You may use some category-specific CSS selectors in your Custom Block. You can add a Page Class in your respective menu items, and change your selector to .my-page-class .com-content-article
2. You may differentiate the category's HTML, or even add the button directly, by creating a template override or a separate layout for this category.
3. You may write {msl_button aid="1"} where 1 is the article ID you want to add. Note that you can place such a button anywhere in your site, and it will add the Joomla article with ID 1 in your list.
Let me elaborate on point 2.
I believe the simplest way to go is to write {msl_button aid="<?php print $this->item->id; ?>"} somewhere in your article code, probably with a template override.
Since you want this to be category specific, you can write a simple PHP check to see if this is the category you want, like so:
Code:
<?php if ($this->item->catid == "15") { ?>
{msl_button aid="<?php print $this->item->id; ?>"}
<?php } ?>
There's also a less hacky way, but it requires a more complex configuration.
Let's assume you want to have a different layout for the single-article page of all articles of category A. You can copy the files components/com_content/tmpl/article/default.php and components/com_content/tmpl/article/default.xml in your templates/your-template/html/com_content/ directory and rename them to mylayout.php and mylayout.xml accordingly. Open the XML file and in line 3 change the layout title attribute to something else, like "My Layout".
Then you can open the PHP file and place the button by writing {msl_button aid="<?php print $this->item->id; ?>"}.
In your category, you can select this new layout as the "Layout" under the Options tab.
I understand this is a lot, so feel free to ask any questions you may have.
As a side note, and for future readers:
If you have multiple lists, you can even write {msl_button aid="1" cp="listprefix"} where listprefix is your List ID (Cookie Prefix) from your module options.
If you want to add items of other components, you can write {msl_button aid="#vm#1"} where #vm#1 stands for Virtuemart Item with ID 1. See our two letter code table for all supported components .
Thanks again!
Christopher Mavros
me@mavxr.com
If you like our extensions, please rate us on the JED!
Please Log in or Create an account to join the conversation.
Moderators: Christopher Mavros