Welcome, Guest
Username: Password: Remember me

TOPIC: How to change Link Content in grid view?

How to change Link Content in grid view? 31 Oct 2012 07:09 #4856

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
Hi,

I want to change the link in the grid-view. This link, links to the Edit View, that's fine.

But where in this code can I add my own text to the contents of the link?

For example:
<a href="index.php?option=com_franchisers&amp;view=klant&amp;layout=klant&amp;cid[]=1&amp;Itemid=163">Techtop</a>
to:
<a href="index.php?option=com_franchisers&amp;view=klant&amp;layout=klant&amp;cid[]=1&amp;Itemid=163"><strong>Custom text here:</strong> Techtop <strong>and some more custom values here</strong></a>

I the default_grid.php there is this code:
<td style="text-align:center">
<?php echo JDom::_('html.fly', array(
'dataKey' => 'rl_bedrijfsnaam',
'dataObject' => $row,
'route' => array('view' => 'klant','layout' => 'klant','cid[]' => $row->id)
));
?>
</td>

Where / how could I add my custom vars/text into the link using the code above?

Regards,

GC
Last Edit: 31 Oct 2012 07:10 by goslingcools.
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 08:06 #4857

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
********EDIT
Apologies, my original reply was to change the link title attribute as opposed to the text on the grid.

Basically, I think you're gonna need to edit your model so that the field rl_bedrijfsnaam get's returned concatenated with your string because the way that JDom is handling this is by referencing the 'dataKey' => 'field' within the $row object.

I'm not 100% sure that this is the best way to do it however, I'm afraid I can't think of a better way for the moment.

In the meantime, you could add a link title as I mentioned before - see below
****************

You should have a link_title element in JDom's html.fly object. Which version of cook are you using and what are your JDom sepcs - condensed? The reason I ask is that your object looks a little different to mine...

Anyway, here's what I have in a standard edit link being generated on a field called title in my table. It is currently just using the text of that field as the link - 'link_title' => $row->title
<?php echo JDom::_('html.fly', array(
	'dataKey' => 'title',
	'dataObject' => $row,
	'link_title' => $row->title,
	'href' => "javascript:listItemTask('cb" . $i . "', 'projectsitem.edit')"
));
?>
So here you could concatenate some static text and other fields as you require. For example;
'link_title' => '<strong>Edit ' . $row->title . '</strong>  - ' . $row->field2 . ' ' . $row->field3
as long as they are fields returned in your row object.

Anyway, hope it helps,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 31 Oct 2012 08:29 by JoomGuy.
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 08:28 #4858

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
1) Do I need to run the Sandbox always first before I Download?

2) My settings are:

JS Framework: jQuery
Form style: Exploded
Features: Reduced
TODO: No

Joomla! compatibility: v2.0 Beta Joomla 2.5


But changing these settings does not change the code... :-(

I keep's using
'route' => array('view' => 'klant','layout' => 'klant','cid[]' => $row->id)

Instead of your
'link_title' => $row->title,
'href' => "javascript:listItemTask('cb" . $i . "', 'projectsitem.edit')"

I need the Form style: Exploded because I want to add some show/hide stuff lateron.
Last Edit: 31 Oct 2012 08:33 by goslingcools.
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 08:34 #4859

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Sorry GC, I was wrong, please see above edited post...
goslingcools wrote:
1) Do I need to run the Sandbox always first before I Download?
No

Is your code
'route' => array('view' => 'klant','layout' => 'klant','cid[]' => $row->id)
the code for an edit task that you've placed on the table or is there a difference in the code because of your JDom config?

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 08:44 #4860

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
What is your config?

JS Framework: xxx
Form style: xxx
Features: xxx
TODO: xxx

Joomla! compatibility: xxx
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 08:52 #4861

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
goslingcools wrote:
What is your config?

JS Framework: jquery
Form style: condensed - this won't make a difference in this case
Features: maximum - this might make a difference
TODO: no

Joomla! compatibility: Cook 2.0/J2.5
Is the element you're adding a link to a field or a specific edit task on the grid?

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 08:57 #4862

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
Thanks!

I tried Maximum too.

It's a Cook's 'default link' to the Edit form.

I think I will manually copy the link and add it to 'mytext'.$row->xxx.$myvar
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 09:01 #4863

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
But what I meant was, is it a task button that you've added in a column on the grid or is it an edit task that you've set on a field?

I'm just trying to workout why your html.fly code looks different - specifically, the link
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
The following user(s) said Thank You: goslingcools

Re: How to change Link Content in grid view? 31 Oct 2012 09:15 #4864

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
Ahaa :-) !

Now I see they are 2 different things!!!

I thought it was: first select the Task / Action, secondly select the Layout.

So you're right, it was set to Layout, and not to Task / Action.

Now changed it to Task / Action and I have the same code as you :-)

I guess the difference between Task and Layout is there if you want to show a fly page at the front-end instead of a form.

Thanks thanks thanks!
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 09:31 #4865

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
I'm just not that sure how best to go about that...

Maybe you could change the protected function prepareQuery(&$query) in your model to do the concatenation . Don't forget that you'll have to assign it as an alias if you do.

In your SELECT statement you'd do something like;
.	'CONCAT("Edit ", a.title) AS my_new_field ',
on the field you want to edit

Hope it helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 09:34 #4866

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
Thanks!

I'll have a try with that lateron and give you the results here.

Thanks again.
The administrator has disabled public write access.

Re: How to change Link Content in grid view? 31 Oct 2012 09:41 #4867

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Just tested!

Works perfectly... One thing to not is that if you want another grid view where you don't want the concatenated text added to the field, i.e. you just want to show the regular field value in the grid, you should ensure that you change your query inside of the right case/switch statement. This will allow you to have independent layouts/views with the different data.

Also, don't forget to change your dataKey to reflect the alias that you've assigned it in your SQL so,
'dataKey' => 'title'
would become
'dataKey' => 'title_alias'
inside your default_grid.php (or whichever one you've changed it in)

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
The following user(s) said Thank You: goslingcools

Re: How to change Link Content in grid view? 31 Oct 2012 10:36 #4868

  • goslingcools
  • goslingcools's Avatar
  • Offline
  • Senior Member
  • Posts: 64
  • Thank you received: 7
  • Karma: 1
Will use this soon! Thanks!
The administrator has disabled public write access.
Time to create page: 0.071 seconds

Get Started