Custom Attributes

Permalink
Good Day all

I have been very impresed with c5 and have managed to create some cool themes and have been impressed with the addon system and addons avaiable. But i am a bit lost when it comes to the custom attibutes section.

All i want is the abilitly to add an attribute to the page properties so that it opens the page no matter if its linked from the auto-nav or a normal link - or the easy news block (mainly this one) so i can set some articles to open in new tabs/windows and some not?

Can any one help i have tryed a copy of posts to do with opening in new tabs but they are for the auto-nav only. Is this possible to do with the page custom attributes?

I have created a tick box attribute for new_tab - Open new tab, but i am now shore were or what to put in the php file? any ideas would be very useful.

I am using concrete 5.4.1.1 havent upgraded yet as i have read a few issues with it!

carl101lee
 
moosh replied on at Permalink Reply
moosh
Hi,

You can't do this in page directly.

You must edit block view or controller where links are used.

For example,
If you use autonav block, make a template for this bock by copying defautlt view, edit it and add 'target="_blank"' for each <a></a>.

Then you can apply this template for any autonav block.

++
carl101lee replied on at Permalink Reply
carl101lee
Thanks ok

So i should be able to do the same for the Easy News block?

as its for a bunch of blog articles displayed in the easy news block i just want one to redirect to a new window - rather than opening it.

I dont surpose you know were the block for easy news is ? would it be concrete/blocks/easynews? at a guess as i can see it!

or can i do it in the web/packages/easy_news/blocks

An assistance is uselful :)

Regards
Carl
moosh replied on at Permalink Reply
moosh
When you make modification on block (core or package), create new block folder with the same name in /blocks folder in the root.

Then copy files you want modified under this new folder.

Otherwise, when you update package or core, your modifications will be overwritten.

In Easy News add-on, in view.php at line 17 you will find :
<a href="<?php  echo $nh->getLinkToCollection($cobj)?>"><?php  echo $title?></a>


If you add "target" attribute in this tag link, all your news will have this target.

To define target by news, you're right, you need to add page attributes, in your example "new_tab" and edit view.php.

1/ You must add this at line 15 :
$target = ($cobj->getAttribute("new_tab")) ? '_blank' : '' ;


2/ Then, edit line 17 :
<h3 class="ccm-page-list-title"><a target="<?php  echo $target?>" href="<?php  echo $nh->getLinkToCollection($cobj)?>"><?php  echo $title?></a></h3>


Normally, working :=)
carl101lee replied on at Permalink Reply
carl101lee
Thanks very much I shall try this now, and let you know.
carl101lee replied on at Permalink Reply
carl101lee
Excellent It work, I think I understand the custom attributes a bit more now. Basicly you can use them to set a variable in the code which you set in the root blocks folder.

Thanks very much I am going to try and mod loads more now. I would like one for splitting the main auto nav into 2 parts so setting the pages to nav 1 or nav 2 If that makes any scene to any one.

If you have any advise feel free.

Many Thanks
Carl Lee
carl101lee replied on at Permalink Reply
carl101lee
Hi Me again

OK a little advise when you get a chance no rush I am on holiday now for a week.
What I have done is create a "Select" page attribute wish to add an option to the Auto nav with values top - bottom to chose from.

Now I need an option on the auto nav to chose to use ever of the options top or bottom.

I though I could use an if statement but that wont work as it will act the same as the exclude_nav option. What I need is to add an option to the auto-nav I guess!

I haven got very far so see below:

public function nav_option() {
    if (nav_select($this->attributeValue)) {
        $value = $this->getAttributeValue()->getValue();
        $this->set('top', $value->top_nav());
        $this->set('bottom', $value->buttom_nav());
    }
}
public function top_nav() {return $this->usethis1;}
public function buttom_nav() {return $this->nousethis1;}


It's not much I know still leaning the basics coming from action script coding.

I am guessing I need to add it in here some were on the view.php for autoNav block

foreach($aBlocks as $ni) {
      $_c = $ni->getCollectionObject();
      if (!$_c->getCollectionAttributeValue('exclude_nav')) {


Thanks for any advise will get back to any comments in 10 days.

Much Love and Thanks
Off on holiday
Carl